View Single Post
  #3   Spotlight this post!  
Unread 14-12-2003, 20:00
Larry Barello Larry Barello is offline
http://www.barello.net
#0492 (Titan Robotics Club)
Team Role: Mentor
 
Join Date: Jan 2002
Location: Bellevue, WA
Posts: 85
Larry Barello has a spectacular aura aboutLarry Barello has a spectacular aura about
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?
Attached Files
File Type: zip Quadrature.zip (1.4 KB, 153 views)

Last edited by Larry Barello : 15-12-2003 at 13:14. Reason: Updated zip file per Mike's suggestions.