Circuit Negma

C++, C, VB.NET, PCB, Electronics, Circuit Design

NOTES :: PIC Timer 0

Posted by Circuit Negma on September 11, 2008


Create By: Hussein Nosair

Few notes on TMR0 module in PIC16 and PIC18 processors.

General Notes for both PIC16 and PIC18 processors from Microchip:

1, Writing to TMR0 register in PIC16 or writing to TMR0L in PIC18 (8-bit mode) or TMR0L, TMR0H in PIC18 (16-bit mode) will clear Timer 0 prescaler’s counter but not assignment.

ex: PIC16

void main(void)
{
    TMR0 = 0x1A;    //<--------- Instruct the PIC to start TMR0 module at 0x1A and increment until reach 0xFF
    PSA = 0b0011;   //<--------- Instruct the PIC to increment TMR0 by 1 after counting 16 Tcyc 
    .//<--------------- Prescaler counter = 0 (reset counter done by wirting to TMR0 register);
    .
    .
    .
    .//<--------------- Prescaler counter =  10
    .
    TMR0 = 0xDF;
    .//<--------------- Prescaler counter = 0 (it has been reset), but still PSA = 0b011
    .
    .
    .
    .
}

2. TMR0 Interrupt
TMR0 overflows from:
0xFF to 0x00                    8-bit mode
0xFFFF to 0x0000             16-bit mode

3. TMR0 cannot be used to wake up the processor (PIC) since it is turned off once the PIC in sleep mode.

4. Prescaler assignment PSA is fully controlled by software, as PSA inhibit the “on-the-fly” feature.

5. Once TMR0 overflow, the new value in TMR0 register is 0x00 (8-bit mode) or 0x0000 (16-bit mode)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: