1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

How to lcdout TMR1 ?

Discussion in 'Oshonsoft' started by jnilo, Mar 15, 2015.

  1. jnilo

    jnilo New Member

    Joined:
    Mar 15, 2015
    Messages:
    9
    Likes:
    0
    TMR1 is a word variable that stores a 16bit timer. However when I write:
    only the dec value of TMR1L shows up on the LCD screen.
    Why is that ? How can I display the full TMR1 variable in decimal ?
     
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,170
    Likes:
    910
    Location:
    Rochdale UK
    Create a long variable.... Say LngTimer!!

    LngTimer = TMR1H
    LngTimer = LngTimer * 256
    LngTimer = LngTimer + TMR1L

    lcdout #LngTimer
     
    • Like Like x 1
  3. jnilo

    jnilo New Member

    Joined:
    Mar 15, 2015
    Messages:
    9
    Likes:
    0
    It works great but it's a bit of black magic to me :) How come a normal word variable can be easily "lcdouted" and not timer1 ?
    Many thanks anyway !
    Jacques
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,170
    Likes:
    910
    Location:
    Rochdale UK

    It depends on the compiler... I looks like a bug to me... I have just given you a workaround..

    TMR1 is TMR1H and TMR1L pair.... With C compilers they can cast ( change its size ) and force it into a word...

    I have no idea how Vladimir does it!
     

Share This Page