Einly
Joined: 10 Sep 2003 Posts: 60
|
Why the leds on Port C keeps on blinking? |
Posted: Fri Dec 03, 2004 3:25 am |
|
|
Dear all,
I am trying to send data from pc to the pic. and from pic to the pc. When I send a byte from the pc to the pic, the pic will get the character and light a led. I connect a max232 between the pc and the pic.
My program looks like this:
#include <16f876.h>
#fuses HS,NOWDT,NOLVP,NOPROTECT,PUT,BROWNOUT
#use delay(clock=20000000)
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7)
#byte PORTC=7
byte a;
#int_rda
void serial_isr()
{
a=getc();
portc=a;
}
void main()
{
set_tris_c(0x80);
enable_interrupts(global);
enable_interrupts(int_rda);
portc=0x02;
do {
} while (1);
}
However, when I send a byte, e.g. 1, the led that is connected to PIN C0 keeps on blinking. Later I change my program to just lights the PIN_C0 without receive data from the pc to check whether the problem is caused by the interrupt. However, the LED is still blinking if the rs232 between the pc and pic still there. If I remove the connection, then it is ok (just light on, without blinking. May I know anyone hav any idea why does this happen?
Thanks _________________ Einly |
|