|
|
View previous topic :: View next topic |
Author |
Message |
jecottrell
Joined: 16 Jan 2005 Posts: 559 Location: Tucson, AZ
|
Calculating Interrupt Overhead |
Posted: Mon Mar 12, 2007 3:03 pm |
|
|
Hello All,
I'm trying to clean up some code and would like to make the ADC sampling clock as accurate as possible. I'm preloading TIMER_1 to get the approximate interrupt rate that I want. But I know there is some overhead involved. Elsewhere, RJ mentions about 20 instructions to get in and 30 to get out? Can I just look at the interrupt in the LST file and add up all the instructions and will that give me the number I'm looking for (after I add it to the 20 & 30)?
For instance...
60 instructions total at 40MHz...
40,000,000/4 = 10,000,000
1/10,000,000 = 0.0000001
60 * 0.0000001 = 0.000006 Overhead for interrupt...
Then compensate the TIMER_1 preload value for this much time?
Thanks,
John |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1636 Location: Perth, Australia
|
|
Posted: Mon Mar 12, 2007 3:11 pm |
|
|
This mechanism is compiler revision dependant. I use a different technique to solve this problem. I take the desired preload value and add it to the current counter contents. This mechanism allows you to deal with situations when the interrupt may have been temporarily disabled in the code or another interrupt handler has control of the PIC. If you are using a low priority interrupt and the system also has a high priority interrupt handler then you need to disable HP interrupts before you reload the timer. You also need to add a very small constant to the reload value to account for the number of cycles the counter reload actually takes. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|