Einly
Joined: 10 Sep 2003 Posts: 60
|
RS232 |
Posted: Fri May 06, 2005 4:11 am |
|
|
Dear all,
I try to transfer RS232 data from the computer to PIC16f876. In the computer, I am using Visual C WriteFile Function. In the PIC16f876, I use an interrupt to check for data. If the first byte sent is 2 (ID), the following byte will be received. However, I noticed that only the first byte is received instead. May I know how should I solve this problem?
#include <16f876.h>
#fuses hs,NOPROTECT,NOLVP,PUT,BROWNOUT,NOWDT
#use delay(clock=20000000)
#use rs232(baud=115200,xmit=PIN_C6,rcv=PIN_C7,PARITY=N)
#include <lcd.c>
#byte PORTA=5
#byte PORTB=6
#byte PORTC=7
byte status=0;
byte smain=0;
#int_rda
void serial_isr()
{
a=getc();
if(a==2 && status==0)
{
status=1;
}
else if(status==1)
{
status=0;
smain=1;
}
}
void main()
{
set_tris_a(0);
setup_port_a(no_analogs);
set_tris_b(0);
set_tris_c(0x85);
lcd_init();
enable_interrupts(int_rda);
enable_interrupts(global);
do
{
if(smain==1)
{
if(a==18)
{
lcd_putc("\f GRAB");
}
else if(a==14)
{
lcd_putc("\f LED 1");
}
}while(1);
} _________________ Einly |
|