che_chia
Joined: 09 May 2011 Posts: 6
|
16F1947 RS232 Can't Receive Data |
Posted: Wed May 11, 2011 9:55 pm |
|
|
The following code is the master send data to the slave. I think the master has sent the data to slave, but the slave can not receive any data from master.
My Hardware Design: xmit=PIN_G1, rcv=PIN_G2. I am Using TX2 and RX2.
Master Code:
include <16F1947.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT
#Fuses INTRC_IO
#use delay(clock=32000000)
#use rs232(baud=9600, xmit=PIN_G1, rcv=PIN_G2, bits=8)
void main()
{
output_bit(PIN_G0,0);
while(1)
{
output_high(Pin_G0);
putc(1);
delay_us(10);
}
}
Slave Code:
include <16F1947.H>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT
#Fuses INTRC_IO
#use delay(clock=32000000)
#use rs232(baud=9600, xmit=PIN_G1, rcv=PIN_G2, bits=8)
int test_1=3;
#byte RC2STA = 0x495
#byte TX2STA = 0x496
#bit OERR = RC2STA.1
#bit FERR = RC2STA.2
#bit SPEN = RC2STA.7
#bit CREN = RC2STA.4
#bit TXEN = TX2STA.5
#byte PIE1 = 0x91
#bit RCIE = PIE1.5
#bit TXIE = PIE1.4
#int_RDA
void RDA_isr(void)
{
if( kbhit() )
{
output_bit(PIN_G0,0);
test_1 = getc();
delay_us(20);
}
}
void main()
{
output_bit(PIN_G0,0);
while(1)
{}
}
Thanks for your help !!! |
|