PIC16F Timer0 clarification

Discussion in 'Embedded Systems and Microcontrollers' started by buddih09, Jun 18, 2012.

  1. buddih09

    Thread Starter New Member

    Dec 21, 2010
    5
    0
    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!
     
  2. kingArgon

    Member

    Mar 20, 2011
    33
    1
    buddih09 likes this.
  3. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    Yes.

    Yes, that's correct. This behavior can be observed in the MPLAB Simulator.
     
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    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.
     
    geoffers, buddih09 and absf like this.
  5. buddih09

    Thread Starter New Member

    Dec 21, 2010
    5
    0
    Thank you very much all.
     
Loading...