You could use a union as follows:
union intchar
{
struct{
unsigned char lo;
unsigned char hi;
}byte;
unsigned int total;
}
union intchar timer1;
union intchar myvar;
timer1.lo = TIMER1L;
timer.hi = TIMER1H;
myvar.lo = CCPR1L;
myvar.hi = CCPR1H;
myvar.total += timer1.total;
CCPR1L = myvar.lo
CCPR1H = myvar.hi
Probably not very efficient though...
Regards
Mike Rigby-Jones
-----Original Message-----
From: Roberto Fonseca Iannini [SMTP:roberto1@LINKEXPRESS.COM.BR]
Sent: Tuesday, November 09, 1999 2:44 PM
To: PICLIST@MITVMA.MIT.EDU
Subject: 8 + 8bits variable
What's the c syntax to perform an 16-bit sum like:
CCPR1 = CCPR1 + TIMER1;
Note that TIMER1 wasn't defined by the 1687x.inc. Instead it was made as
TIMER1H and TIME1L (each one 8 bits type). The same is true to CCPR1.
Summarizing: How can I define or use a new 16 bit variable called
TIMER1 that is formed by TIMERH and TIMERL (MSB and LSB)?
(this code is for 16F877)
See you guys,
Beto.