News:

;) This forum is the property of Proton software developers

Main Menu

1 sec interrupt from 16MHz internal clock

Started by shantanu@india, Nov 01, 2022, 10:36 AM

Previous topic - Next topic

shantanu@india

I have a 18F24K22 where I need a 1 sec TMR0 interrupt routine. I set the prescaler to 1/256 and the clock to instruction cycle. If I preload TMR0H and TMR0L with 49910 then the timer generates interrupt after (65535-49910)*(1/4)*(256)=1000000 microsec =1 second.
Are my calculations OK?
Regards
Shantanu

trastikata

Excluding writes to TMR0, I get 1.000064s with a 49910, and 1s with 49911. Writes to TMR0 are two cycles if I am not mistaken, thus 49909 for 1s interrupt.

shantanu@india

Regards
Shantanu