|
Re: Problem with interrupts on the PIC
I wrote a quadrature decoder for the PORTB change state interrupt pins (RB4-7, or IFI 3-6). It is simple and works great. Just enable the RB interrupt, assign it to low priority and enable global interrups and it works. I call my routine from the user_function_fast.c module in the low interrupt handler.
However. The system doesn't work. As my shaft turns and the counts are accumulated the servo output pulses glitch and the serial I/O over the program port glitches. If I run my encoder fast enough the entire system crashes.
Attached is the code.
I have done a lot of embedded small system programming and I know what I am doing, however, this is my first time with a PIC, so there could be something I don't understand. But looking at the dissasembly code it all looks ok. Interrupts off upon entry, re-enabled upon exit, call a single routine.
Any ideas? It sure looks like a classic race condition where something is crapping on something else. Maybe this is a C compiler thing?
Last edited by Larry Barello : 15-12-2003 at 13:14.
Reason: Updated zip file per Mike's suggestions.
|