18F4620 TMR1 Oshonsoft

Thread Starter

camerart

Joined Feb 25, 2013
3,831
hi,
As I said TMR1 is an UP counter , so if you load it with 3036 decimal, it will have to count up to 65536, at which time it will over flow to 0000o and generate an Interrupt.
So 65536-[with a pre load of 3036] = 62500 counts to an interrupt.
As the PLL clock is 32MHZ, divided by 4= 8MHz and you are using the pre-scaler at divide by 8, the TMR1 clock= 1MHz,,,, which is 1uSec period per clock pulse.

So an Interrupt occurs every 62500uSec ie: 0.0625Seconds.
If you want to get an action, like get_msg every 0.5Secs, you have to count the number of interrupts, in this case 8 * 0.0625s = 0.5Seconds

Do you follow.?
E
Hi E,
I follow. I had forgotten that it UPCOUNTS, and you had calculated a division of 0.5S.

[[ So you need to load TMR1 with 65536- 62500 decimal ie 0xFFFF - 0xF424 = 0x0BDB== [ 3036 dec] == 8 times 0.0625Seconds = 0.5Sec. ]]

62500 = 0.0625Seconds X 8 = 0.5S.
____________________________________________________________
Result of the SIm TEST. Shown in REAL TIME DURATION
First BREAK 608.00
Second BREAK 500928.50 = 0.50
___________________________________________________________

Thanks.
C.
 
Last edited:
Top