UTMonkey
Member
Hi All,
instead of tagging this (side question) on the end of an existing thread, I thought I would create a new one.
Can someone check if I have this right, This is not for any particular project - just for my own knowledge (and also I would like to know what the experts do!).
I would like to be able to get a PIC to generate an accurate(ish) trigger.
My previous thread mentions a 300hz trigger from a PIC running at 8Mhz (2MIPS).
Thanks to Mister E who directed me to his utility to find the best values to plug into my timer:-
Prescaler 1:1
Reload 58876
Are the following assumptions correct:-
1. My interrupt service would contain at the very beginning code to "reload" 58876 to the various timer registers, previous threads have suggested that the TIMERx keeps on ticking whilst an interrupt is serviced but won't trip on a rollover until my interrupt service tells it to do so (at the end). I would imagine this ensures that each interrupt is called as close to 300 times a second.
2. If assumption 1 is true then, any delays that are built into the main code (such as the kind done by delay code generators) must be recalculated based on the cycles used in servicing the interrupt.
Example:
My interrupt must be occur once every 3.3 milliseconds (300hz), that means for a PIC running at 8Mhz (2MIPS) there are (roughly) 6666 ticks between each interrupt.
Lets say my interrupt service takes 1000 ticks (a lot I know), that means that there are 5666 ticks left for my main body of code. So to put a "count to 5 minutes" delay in the main code would actually take longer (roughly over 15% longer).
Have I got this right? what do the experts do?
Many thanks in advance.
Mark
instead of tagging this (side question) on the end of an existing thread, I thought I would create a new one.
Can someone check if I have this right, This is not for any particular project - just for my own knowledge (and also I would like to know what the experts do!).
I would like to be able to get a PIC to generate an accurate(ish) trigger.
My previous thread mentions a 300hz trigger from a PIC running at 8Mhz (2MIPS).
Thanks to Mister E who directed me to his utility to find the best values to plug into my timer:-
Prescaler 1:1
Reload 58876
Are the following assumptions correct:-
1. My interrupt service would contain at the very beginning code to "reload" 58876 to the various timer registers, previous threads have suggested that the TIMERx keeps on ticking whilst an interrupt is serviced but won't trip on a rollover until my interrupt service tells it to do so (at the end). I would imagine this ensures that each interrupt is called as close to 300 times a second.
2. If assumption 1 is true then, any delays that are built into the main code (such as the kind done by delay code generators) must be recalculated based on the cycles used in servicing the interrupt.
Example:
My interrupt must be occur once every 3.3 milliseconds (300hz), that means for a PIC running at 8Mhz (2MIPS) there are (roughly) 6666 ticks between each interrupt.
Lets say my interrupt service takes 1000 ticks (a lot I know), that means that there are 5666 ticks left for my main body of code. So to put a "count to 5 minutes" delay in the main code would actually take longer (roughly over 15% longer).
Have I got this right? what do the experts do?
Many thanks in advance.
Mark