Maker Pro
Maker Pro

Microcontroller execution time

electronicsLearner77

Jul 2, 2015
306
Joined
Jul 2, 2015
Messages
306
I have a timer and if i configure it for 1ms the execution time of main function from the beginning to end will be less compared to the same timer configured for 500 micro seconds. Is it correct? Or there will not be any difference. The controller is a pic. Please suggest.
 

Minder

Apr 24, 2015
3,478
Joined
Apr 24, 2015
Messages
3,478
Depends what source you are using to run the timer, if the system clock then it will depend on the freq of the clock (Fosc/4) and the pre-scale the timer is set for.
You can pre load the timer with any value and then check the over flow after changing timer value.
M.
 
Last edited:

electronicsLearner77

Jul 2, 2015
306
Joined
Jul 2, 2015
Messages
306
I think i have not explained my question properly. My question was if i increase the frequency of timer interrupt (for that matter any interrupt) then it will load the sytem more and hence other functions will take more time to finish. Similarly if i decrease the timer interrupt frequency then less time for other functions to finish. Am i correct?
 

Minder

Apr 24, 2015
3,478
Joined
Apr 24, 2015
Messages
3,478
If the timer period is reduced and you are using a Interrupt location routine, Then obviously the more often the interrupt is called it will increase the time taken for non-interupt routines to perform their task etc.
In some cases, instead of using the interrupt locations is to turn off GIE etc and just poll the interrupt bit, which will still be set regardless.
M.
 
Top