PIC16F Timer0 clarification

Thread Starter

buddih09

Joined Dec 21, 2010
5
Hi,

I think this is a very simple question for many of you but since I'm new to the PIC world I need your help to understand this. Please help.

When I read the user manual I found the following statements that I cannot understand well.

"When the prescaler is assigned to the Timer0 module, any write to the TMR0 register will immediately update the TMR0 register and clear the prescaler."

Does this mean the prescaler gets reset at every time Timer0 writes to TMR0 register?

And the second statement completely avoids me.

"The incrementing of Timer0 (TMR0 and Prescaler) will also be inhibited 2 instruction cycles (TCY). So if the prescaler is configured as 2, then after a write to the TMR0 register TMR0 will not increment for 4 Timer0 clocks. After that, TMR0 will increment every prescaler number of clocks later."

Please help me to understand what these mean.

Thank you!
 

MMcLaren

Joined Feb 14, 2010
861
"When the prescaler is assigned to the Timer0 module, any write to the TMR0 register will immediately update the TMR0 register and clear the prescaler."

Does this mean the prescaler gets reset at every time Timer0 writes to TMR0 register?
Yes.

And the second statement completely avoids me.

"The incrementing of Timer0 (TMR0 and Prescaler) will also be inhibited 2 instruction cycles (TCY). So if the prescaler is configured as 2, then after a write to the TMR0 register TMR0 will not increment for 4 Timer0 clocks. After that, TMR0 will increment every prescaler number of clocks later."
Yes, that's correct. This behavior can be observed in the MPLAB Simulator.
 

Markd77

Joined Sep 7, 2009
2,806
The prescaler is a counter that you can't read or write to directly. Let's say the prescaler is set to 16, TMR0 will increment every 16 instruction cycles. The value that the prescaler is set to won't change unless you change it. What you can do is change the value of TMR0, eg CLRF TMR0. When you change TMR0 the prescaler count is also reset to zero, but the prescaler value doesn't change.
After changing TMR0 nothing changes for 2 instruction cycles so with prescaler set to 16, TMR0 will not increase for 18 instruction cycles.
 
Top