There are two many unknowns.16 bit, 5 time and want to count for a Mhz count up for a 3 ms interval. What value should I put in data register. How to calculate this.
Thanks for the help
Jey
16 bit, 5 MHz count up timer and want to count up for a 3 ms interval. What value should I put in data register. How to calculate this.
Thanks for the help
Jey
If you mean that you increment the counter every 200 nS (5 Mhz) then you need to count to 15000 (Decimal) Normally counters set their interrupt flag when they overflow so you need to pre load the counter with 15000 less than the overflow value. A 16 bit counter will overflow at a count of 65536 so you need to pre load it with a value of 65536 -15000 = 50526 which is 0xC568 Hex. In practice you have to make a correction for the time it takes to load the counter. You write the code required to load the counter then work our how long those instructions take to execute. You then add the number of cycles of 5Mhz that represent that amount of time to the value you load into the counter.
Les.
Thanks for you support.0x7A2B = 31275 decimal. As you are now talking about a count down timer (Rather than a count up timer.) the situation is different. (I have not seen a countdown timer on any of the microcontrollers that I have used.) I ASSUME that in this case the interrupt would occur when the counter decremented to zero. (You would have to read the datasheet on the microcontroller that you are using.) If my assumption is correct then the actual counting part would last 31275 x 100 nS = 3127.5 uS
Les.
by Robert Keim
by Jake Hertz
by Robert Keim