Hi, I set up my timer3, but the TMR3 counte don't change.
My init function:
TMR3CN = 0x00; // Timer3 configured for 16-bit auto- // reload, low-byte interrupt disabled CKCON &= ~0x40; // Timer3 uses SYSCLK/12 TMR3RL = (U16) -(SYSCLK/12/40); // Timer3 configured to overflow after TMR3 = TMR3RL; // ~25ms (for SMBus low timeout detect) EIE1 |= 0x80; // Timer3 interrupt enable TMR3CN |= 0x04;
After init the SFRs page for timers show:
TCON = F0 TMOD = 22 CKCON = 04 T0 = 0032 T1 = 96E9 TMR2 = 0000 TMR3 = 389F TMR2CN = 00 TMR2RL = 0000 TMR3CN = 04 TMR3RL = 389F
and interrupt section is :
IE= 91 IP = 81 EIE1 = 81 EIP1 = 81 EIE2 = 00 EIP2 = 00 IT01CG = 06
if I use debug step I see other timer change their value, but not timer3.
Can someone help me?
I did not reproduce your issue by putting your code into the example code (initially for timer2).
Hi delu, thanks for your test.
I also try to use a project only for timer3 and it works.
So somethings is wrong in other part of code.
But if I see SFR of Timer, Oscillator, and Interrupt the value are the same, so there is any other register that can cause the block of timer3?
In attached there is a screenshoot of my program when it reaces the while loop. You can see the SFR on the right.
P.S.: in your code there is a TMR2RL cal in timer init. :-)
I found the problem.
SMBTOE was set to 1.
So if SCL is high ( as is beacause is the standard condition of I2C bus) the SMBUS force timer3 to reload.
So I see in SFR alway the reload value.
Clearing SMBTOE everytihng woks fine.
Thanks for your test.