How to lcdout TMR1 ?

Status
Not open for further replies.

jnilo

New Member
TMR1 is a word variable that stores a 16bit timer. However when I write:
lcdout #TMR1
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 ?
 
Create a long variable.... Say LngTimer!!

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

lcdout #LngTimer
 
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
 
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!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…