I found out that in the F452.H header file particularly the line stated below:
long CCP_1;
#byte CCP_1 = 0xfbe
#byte CCP_1_LOW= 0xfbe
#byte CCP_1_HIGH= 0xfbf
Why is that CCP_1 was declared as a 16bit variable? I try to look at the F452 data sheet and found-out that 0xFBE register address for CCP_1 is an 8bit register?
One more thing CCP_1_LOW has the same address with CCP_1 which is of different data types. I understand that CCP_1_LOW is an 8bit register.
With this the declaration long CCP_1 only uses the lower 8bit rather than the 16bit lval.
Is their another way of defining and using the CCP_1 such that it can be easily ported to other C Compiler?
Anyone can explain it why this is so?
Thnx
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Sat Feb 05, 2005 3:25 am
Read section 14.3 Capture Mode of the 18F452 data sheet.
Read the first sentence in that section.
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
Posted: Sat Feb 05, 2005 1:43 pm
The CCP register is composed of 2 bytes. A low byte and a high byte. The 16 bit variable is so you can assign the by a 16 value rather than a having to do 2 8bit assignments. It is correct BTW.
chingB
Joined: 29 Dec 2003 Posts: 81
Posted: Sun Feb 06, 2005 1:00 am
I want to change the definition of the line stated below <w/o using #byte>:
long iCCP_1;
#define iCCP_1 *((unsigned int *) CCPR1L)
#define iCCP_1_LOW *((unsigned int *) CCPR1L)
#define iCCP_1_HIGH *((unsigned int *) CCPR1H)
Would this code replacement possible? I need your comments and suggestions such that my code will not use the #byte preprocessor for easy porting to other PIC C-Compiler.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum