CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

CCP1 F452 Module Inquiry

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
chingB



Joined: 29 Dec 2003
Posts: 81

View user's profile Send private message

CCP1 F452 Module Inquiry
PostPosted: Sat Feb 05, 2005 3:02 am     Reply with quote

Hello,

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

View user's profile Send private message

PostPosted: Sat Feb 05, 2005 3:25 am     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Sat Feb 05, 2005 1:43 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Feb 06, 2005 1:00 am     Reply with quote

I want to change the definition of the line stated below <w/o using #byte>:
Code:

long CCP_1;
#byte CCP_1 = 0xfbe
#byte CCP_1_LOW= 0xfbe
#byte CCP_1_HIGH= 0xfbf


with code below

Code:

#define CCPR1L    (0xFBE)
#define CCPR1H    (0xFBF)

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.

Thanx
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group