Hello there .
I have successfully accomplished TMR0 and TMR1 interrupts , but TMR2 is totally different in configuration , i don't understand how to set PR2 value for a fixed time .
So basically what i do when setting up TMR0/1 is using this equation :
Count = Fosc/(4*Prescaler*Fout*(2^timer bits - Timer count start )
So for example for 1 sec we have 1 hz as Fout , using a 16 MHz quartz and tmr0 ,and a prescaler of /128 , i end up with this equation :
count = 31250/(256 - TMR0 ) , after that i try to find out a count number that is close enough to an enteger to have exactly 1 second delay .
For that i play with the equation varying the timer count start until i find out the correct count number that will be used as variable in the interrupt program :
So if i take for example 31250/(256-110) i get a count of 214 overflows to accomplish a TMR0 flag , the TMR0 value is 110 then.
I don't know if i can use the same approach with TMR2 ??
I have successfully accomplished TMR0 and TMR1 interrupts , but TMR2 is totally different in configuration , i don't understand how to set PR2 value for a fixed time .
So basically what i do when setting up TMR0/1 is using this equation :
Count = Fosc/(4*Prescaler*Fout*(2^timer bits - Timer count start )
So for example for 1 sec we have 1 hz as Fout , using a 16 MHz quartz and tmr0 ,and a prescaler of /128 , i end up with this equation :
count = 31250/(256 - TMR0 ) , after that i try to find out a count number that is close enough to an enteger to have exactly 1 second delay .
For that i play with the equation varying the timer count start until i find out the correct count number that will be used as variable in the interrupt program :
So if i take for example 31250/(256-110) i get a count of 214 overflows to accomplish a TMR0 flag , the TMR0 value is 110 then.
I don't know if i can use the same approach with TMR2 ??