For PIC24/dsPIC33 with 140MHz MCU clock frequency the Timer1 calculated C code is:
Code: Select all
//Timer1
//Prescaler 1:8; PR1 Preload = 8750; Actual Interrupt Time = 1 ms
//Place/Copy this part in declaration section
void InitTimer1(){
T1CON = 0x8010;
T1IE_bit = 1;
T1IF_bit = 0;
IPC0 = IPC0 | 0x1000;
PR1 = 8750;
}
void Timer1Interrupt() iv IVT_ADDR_T1INTERRUPT{
T1IF_bit = 0;
//Enter your code here
}
That is, it starts from 0 and doesn't reset until one TMR1 increment after the match/interrupt.Timers using a timer input clock prescale = N (other than 1:1) operate at a timer clock rate
(PBCLK / N), and the TMR1 Count register increments on every Nth timer clock rising edge. For
example, if the timer input clock prescale is 1:8, the timer increments on every eighth timer clock
cycle. The timer continues to increment until the TMR1 Count register matches the PR1 Period
register value. The TMR1 Count register then resets to 0x0000 after ‘N’ more timer clock cycles,
and then continues to increment and repeats the period match until the timer is disabled.
Can you confirm this?
Thanks