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 CCS Technical Support

SFR definitions, another method apart from structures

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



Joined: 08 Sep 2004
Posts: 5
Location: Ipswich

View user's profile Send private message

SFR definitions, another method apart from structures
PostPosted: Fri Jan 07, 2005 6:20 am     Reply with quote

I have recenrtly started coding using this compiler and found the lack of SFR definitions disappointing. In defining my own I found that the recommended way involves structures. I found that using this method gave poor result in 'if' statements(it didn't work!). A better way of doing this is:

// ADCON0
#bit ADON = 0x0FC2.0
#bit GO_DONE = 0x0FC2.1
#bit CHS0 = 0x0FC2.2
#bit CHS1 = 0x0FC2.3
#bit CHS2 = 0x0FC2.4
#bit CHS3 = 0x0FC2.5
#byte ADCON0 = 0x0FC2

instead of the structure method:

// ADCON0
extern struct {
unsigned ADON:1;
unsigned GO_DONE:1;
unsigned CHS0:1;
unsigned CHS1:1;
unsigned CHS2:1;
unsigned CHS3:1;
unsigned unused:1;
unsigned unused:1;
} ADCON0bits;

#byte ADCON0bits = 0x06
#byte ADCON0 = 0x06
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Fri Jan 07, 2005 7:08 am     Reply with quote

They work just fine. Maybe yours didn't work because of this change to the compiler

The compiler operation concerning type conversions to an int1 have changed to
be ANSI compliant.
Old way:
onebit = eightbits; // Same as: onebit = (eightbits != 0)

New way:
onebit = eightbits; // Same as: onebit = (eightbits & 1)
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