16F1937 8bit timer 2/4 & 6

Moderator: Benj

Post Reply
medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

16F1937 8bit timer 2/4 & 6

Post 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.
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

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

Post 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.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

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

Post 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
Martin

Post Reply