reading / resetting timer0 in 16 bit mode


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326

    Default reading / resetting timer0 in 16 bit mode

    good day to all in this forum,
    I am using pic18f877 as a counter and I would like to use timer0 in 16 bit mode for reading an external signal.
    At the moment I am not able to read the whole 16 bit content of the timer correctly.
    Any sample picbasic code please ? / any help please ?
    Thank in advance
    regards,
    Bye

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: reading / resetting timer0 in 16 bit mode

    I didn't know there was an PIC18F877 and I can't seem to find a datasheet for it so I would guess you're using the 16F877 but that doesn't have a 16bit TMR0 so you'd need to clarify that a bit.

    But generally speaking, you read the TMR0L first which latches the high byte of the timer/counter into TMR0H for you to read.
    Code:
    myCount VAR WORD
    
    myCount.BYTE0 = TMR0L    ' Get low byte and latch content of high byte
    myCount.BYTE1 = TMR0H   ' Get high byte
    /Henrik.

  3. #3
    Join Date
    Jun 2008
    Location
    Varese , Italy
    Posts
    326


    Did you find this post helpful? Yes | No

    Default Re: reading / resetting timer0 in 16 bit mode

    Thanks Henrik;
    I am sorry for the PIC type: it is a PIC18F452.
    I understand that I must read the low byte first and then read the high byte.
    I must write the high byte first and then write the low byte ...
    Am I correct please ?
    Thanks
    Bye

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default Re: reading / resetting timer0 in 16 bit mode

    That is correct.

Similar Threads

  1. Replies: 10
    Last Post: - 26th July 2018, 05:14
  2. PIC18f2620 Timer0 in 16-bit mode
    By Bruce in forum General
    Replies: 0
    Last Post: - 18th August 2010, 04:08
  3. Setting / resetting a variable bit within a byte
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 9th February 2008, 19:38
  4. LCD in 8-bit mode
    By thesaxmachine in forum General
    Replies: 1
    Last Post: - 7th April 2006, 09:10
  5. LCD 4-bit mode affecting rest of port?
    By Mark Scotford in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 22nd August 2005, 09:43

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