PDA

View Full Version : incrementing 16 bit timer value



queenidog
- 23rd May 2015, 15:07
I have TMR1 loaded with $FC7C, using the commands TMR1H=$FC and TMR1L=$7C.

I was hoping to make this one variable like T1Val=$FC7C so that I can increment or decrement this timer value. Can this be done? Can I concantenate both bytes as in T1Val=TMR1H +TMR1L (where T1Val var word)?

Tabsoft
- 23rd May 2015, 15:16
Sure you can do what you want.

T1Val var word
T1Val = $FC7C

TMR1L = T1Val.BYTE0
TMR1H = T1Val.BYTE1

queenidog
- 24th May 2015, 14:11
So I can write: T1Val=T1Val+1 resulting in T1Val incrementing from FC7C to FC7D?

Tabsoft
- 24th May 2015, 14:36
Yes.

The "Using Scaler Variables" section in the PBP manual describes this.

You can do this:

T1Val = $FC7C
T1Val = T1Val + 1 ' $FC7D

TMR1L = T1Val.BYTE0 ' $7D
TMR1H = T1Val.BYTE1 ' $FC

Timer1 now equals $FC7D