Page 1 of 1

UART Interrupt not working (V4.5)

Posted: Wed Oct 31, 2012 12:07 pm
by Dave S
Hi,

I can't seem to get the UART interrupt working (see attached code) in V4.5. If I put the IF statement in RxInt into the main loop and don't use the interrupt all works well. Unfortunately I need it to work from the interrupt fot the next stage. I have tried manually setting Intcon, PIE1 and PIR1 to no avail. Any ideas please?

Thanks,

Dave.
RS232Strings.fcf
(11.5 KiB) Downloaded 423 times

Re: UART Interrupt not working (V4.5)

Posted: Wed Oct 31, 2012 12:40 pm
by Benj
Hi Dave,

Please try adding the following line of code in a C icon at the start of your program and let me know how you get on.

Code: Select all

set_bit(intcon, PEIE);
Edit. Hmm I see your already doing this. The GEIE and RCIE lines of code should not be required and your RxInt macro is incorrect, the C code may not work correctly.

Here is a quick test program for your hardware to see if the interrupt is working at all.
IntTest.fcf
(7.5 KiB) Downloaded 445 times
If still nothing then have you done a 1 second flasher test on the hardware to ensure your clock speed and config is correct?

Re: UART Interrupt not working (V4.5)

Posted: Wed Oct 31, 2012 12:47 pm
by Benj
Whoops the RxInt macro should set RxRec to 0 not 1.

Re: UART Interrupt not working (V4.5)

Posted: Wed Oct 31, 2012 2:37 pm
by Dave S
Well that works fine Ben. Gives me something to work with.

Thanks,

Dave.