Hi everyone! I'm developing a project with pics and now i'm testing serial communication through rs232, using a pic, a max232 converter and my laptop.
The problem is simple to explain, but i don't know how to get over it and what i'm doing wrong..
When i establish a communication without using interrupts (Interrupt Service Routine), the communication works just fine. The problem is that i need to use the ISR on the main project. To test the communication with ISR, i created this simple program, but it doesn't work.
Can someone see any programming error or have any suggestion to help me solve this situation?
I'm using MPLAB IDE to develope code, using the compiler HI-Tech ANSI C Compiler..
Thanks in advance!
The above code works ok for me in ISIS .... However I'm using the built in terminal.... There is a danger that if the data coming in is too fast the "DataArrival()" may still be executing when the ISR triggers again.... This will generate a recursive loop which would bomb out very quickly.
either buffer your input, or slow down incoming data.
If you think the PIC is not running, then strip out everything and just flash an LED. When you get it running then add your functions back one at a time and debug as you go. One thing I noticed is that you call another function from within the ISR. This is not good practice; a better way is to use a flag variable and set the flag in the ISR, then poll for the flag in your loop.
i've made the changes that you all suggested, but the pic doesn't even start too. I've removed the interrupt routine, it works fine. But i need to use other interrupts, far ahead, so i can't skip the interrupt problem because it will happen later.
I've changed the code, but still with no results.. This is the new version but with the same results..
i've made the changes that you all suggested, but the pic doesn't even start too. I've removed the interrupt routine, it works fine. But i need to use other interrupts, far ahead, so i can't skip the interrupt problem because it will happen later.
I've changed the code, but still with no results.. This is the new version but with the same results..
void interrupt peee(void)
{
if(RCIF==1)
{
Rx=RCREG;
ale=1;
}
You are missing something in your interrupt routine, a return..
From the HiTechC manual
int tick_count;
void interrupt tc_int(void)
{
if (T0IE && T0IF) {
T0IF=0;
++tick_count;
return;
}
// process other interrupt sources here
}
Hope that helps...
I am not good with interrupts either...
Everyone.... It simulates fine in ISIS... Its not working in the real world. Can you show me your circuit diagram? What is connected to the INT pins etc...
Yep, in ISIS it works fine.
I'm using a PICDEM 2 PLUS DEMO BOARD, with nothing connected to the INT pins. If i remove the interrupt function, it transmits fine, and if i don't use the interrupt function and use other way to read the RCIF, it communicates just fine. But there's some problem with the Interrupt function..
By the way, when i build the code, it warns me for "missing newline" ...