View Single Post
  #4   Spotlight this post!  
Unread 07-02-2008, 15:07
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,171
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: How many interrupts is too many interrupts?

There are many things to consider when asking how many interrupts is too many. It takes some time for the processor to get into and out of interrupt context. The PIC is pretty fast, 5us or so I think. Then when you get into interrupt context, it takes some time to save the registers and restore them. This maybe adds another 5us, probably less. So if it takes 10us per interrupt and you generate 100,000 per second you are hosed. One assumes we want to do something in the ISR, lets say that you do 40us of work in the ISR. Now you have 50us total per interrupt so if you generate 20,000 per second you are hosed.

So consider how much time you spend in interrupt context and how many interrupts are generated per unit time. Then you have other considerations. How much of the total bandwidth can you spare? You can't miss the deadlines sending messages back to the OI so add up the amount of time you spend in your slow routine plus the fast routine plus the max amount of time in ISRs during any 23ms period. If the WORST CASE numbers add up to more than 23ms, you have to change something. Make sense?

We have no troubles with encoders generating 4,000 interrupts per second and the serial port another 1200 or so per second. The only really complicated stuff going on in our normal code are a couple integer PID calculations.

HTH