Page 1 of 1

Adding CCP1 (CCPR1L CCPR1H) registers.

Posted: 29 Mar 2009 03:33
by sparky
Hi all,

I want to get the total captured contents of the CCPR1L (low byte) and CCPR1H (high byte) registers.

Should I do it like this: CCPR1L + (CCPR1H<<8).

Or just like this: CCPR1L + CCPR1H.

Thanks for any help.

Posted: 29 Mar 2009 13:57
by Nick101
Hello,
It can be CCPR1L + (CCPR1H<<8 ) or (CCPR1H*256) + CCPR1L or get them direct from define address 0x15 unsigned varible

Code: Select all

unsigned CCPR1 absolute 0x15;
CCPR1 always contains CCPR1H:CCPR1L

Posted: 30 Mar 2009 09:22
by sparky
Hi Nick,

Thanks for your answer.

I like your idea about reading data straight from the address however 0x15 is only for CCPR1L right?. Would I need to read 0x16 (CCPR1H) also and then add them together and name it CCPR1? I guess if I did that it would be easier for me to use the register names. Sorry for what I'm guessing are silly questions.

I forgot to mention, this is for a 16F88.

Thanks again for your help.

Sparky.

Posted: 31 Mar 2009 02:02
by Nick101
Hi,
You don't have to read 0x16 because reading unsigned varible is already reading 2byte.

Posted: 31 Mar 2009 06:53
by sparky
Hi Nick,

That makes sense. I am not really used to going direct to the address, you've helped me get a step closer to understanding how it works, thanks for that!

Great website by the way!

Sparky.