CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Calculating Interrupt Overhead

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

Calculating Interrupt Overhead
PostPosted: Mon Mar 12, 2007 3:03 pm     Reply with quote

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: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Mar 12, 2007 3:11 pm     Reply with quote

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!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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