Timer Issues


Closed Thread
Results 1 to 5 of 5

Thread: Timer Issues

  1. #1
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429

    Default Timer Issues

    Correct me if i'm wrong, but I should be able to set the value of TMR0L and TMR0H to whatever I like yes?

    If I do this as a test:

    Code:
    DEFINE OSC 48
    
    T0CON=%10010110
    
    TMR0L=0
    TMR0H=0
    
    pause 200
    
    result.LowByte=TMR0L
    result.HighByte=TMR0H
    The result varies every time i do it. As if reseting TMR0L and TMR0H is doing nothing.

    However if I do this:


    Code:
    DEFINE OSC 48
    
    T0CON=%10010110
    
    result1.LowByte=TMR0L
    result1.HighByte=TMR0H
    
    pause 200
    
    result2.LowByte=TMR0L
    result2.HighByte=TMR0H
    
    result=result2-result1
    The result is correct every time.

    Does anyone know why?
    Last edited by Kamikaze47; - 7th September 2007 at 13:36.

  2. #2
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    TMR0 is 8-bit.

    Which PIC is it?


    -------------------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Nope. Got TMR0 set to 16-bit.

    18F4550

    I've updated the code in the 1st post with the TMR0 settings

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default

    Timer config is 16 bits ...

    Why not write Highbyte first ... as datasheet explains ...


    " Similarly, a write to the high byte of Timer0 must also
    take place through the TMR0H Buffer register. The high
    byte is updated with the contents of TMR0H when a
    write occurs to TMR0L. This allows all 16 bits of Timer0
    to be updated at once."

    Alain
    Last edited by Acetronics2; - 7th September 2007 at 14:22.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    That did the trick.

    Thanks Acetronics.

Similar Threads

  1. Elapsed Timer Demo
    By Darrel Taylor in forum Code Examples
    Replies: 111
    Last Post: - 29th October 2012, 17:39
  2. Timer + rc5
    By naga in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 19th November 2009, 07:56
  3. Understanding timer issues
    By boroko in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 7th April 2009, 02:56
  4. Timer interrupt frequency
    By Samoele in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th January 2009, 23:49
  5. timer interupt help 16f73
    By EDWARD in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd July 2005, 08:41

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts