Page 1 of 1

16F1937 8bit timer 2/4 & 6

Posted: Fri Aug 23, 2019 8:31 am
by medelec35
As timer 2/4 & 6 are 8 bits, they should not default to(or allow) 256 rollover value:
8 bit timer.png
(25.05 KiB) Downloaded 928 times
When OK is clicked on the values are excepted.

Re: 16F1937 8bit timer 2/4 & 6

Posted: Wed Aug 28, 2019 3:58 pm
by Benj
Hi Martin,

The rollover of 256 as the default is correct.

The interrupt occurs when the count register goes from 255 to 0 e.g. the 256th count.

0 to 1 = count 1
1 to 2 = count 2
...
254 to 255 = count 255
255 to 0 = count 256

We use the rollover value - 1 behind the scenes in the rollover register so 256 would become 255 for say the PR2 register.

Re: 16F1937 8bit timer 2/4 & 6

Posted: Wed Aug 28, 2019 4:16 pm
by medelec35
Hi Ben,
Benj wrote:We use the rollover value - 1 behind the scenes in the rollover register so 256 would become 255 for say the PR2 register.
Ah I did not know that.
Thank you, that would explain it