View Single Post
  #6   Spotlight this post!  
Unread 07-02-2008, 10:55
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: How many interrupts is too many interrupts?

At 20,000 interrupts per second, you would need a interrupt code path length of 500 instruction cycles or less (processor is capable of 10,000,000 instruction cycles/second). In almost all cases with the robot, the interrupt code path should be well under 500 cycles leaving upwards of half of the cycles for non-interrupt code.

Typically in MPLAB/IFI default code the interrupt code paths I've measured are <250 cycles total as long as context save/restore is managed well and closer to 500 for WPILib based projects - mostly due to the larger context save/restores needed for accepting anyone's service routine. Probably the longest code path I've seen is in adc interrupt handlers becuase of array indexing and averaging which isn't needed for most other device interrupt routines, but still the average is <300 instructions (~110 cyles per sample and a max of about 1800 cycles for processing 16 channels at sample set boundaries for an average around 215-220 cycles).

Which means, with tuning you'd be easily able to process in excess of 40,000 interrupts per second before you'd start max'ing out the processor.

The down side is, as the process runs more and more at interrupt level there is less and less time at user level and you can get the red light of death because the user code isn't exchanging data in a timely manner with the master processor. You can get around this issue by doing the Getdata/Putdata at interrupt level tied to the system clock for example.

Last edited by dcbrown : 07-02-2008 at 10:58.