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

typedef struct -> Nb of bits out of range

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



Joined: 29 Dec 2007
Posts: 122
Location: Ireland

View user's profile Send private message

typedef struct -> Nb of bits out of range
PostPosted: Wed Jan 09, 2008 2:25 pm     Reply with quote

Hello everybody,
I have a problem when I try to creat a structure:

Code:
typedef struct
{
   unsigned int   PLLDIV:9;
   unsigned int   b9:1;
   unsigned int   b10:1;
   unsigned int   b11:1;
   unsigned int   b12:1;
   unsigned int   b13:1;
   unsigned int   b14:1;
   unsigned int   b15:1;
}_Def_SFR_PLLFBD;


I've got an error message at this line:
Code:
unsigned int   PLLDIV:9;

It says:
"Number of bits is out of range".

Do you have an idea about my mistake?

Thanks for any answer,
Franck.
Ttelmah
Guest







PostPosted: Wed Jan 09, 2008 3:13 pm     Reply with quote

How big is an int in CCS?.
What is the maximum number of bits allowed in a bitfield therefore?...

Best Wishes
Franck26



Joined: 29 Dec 2007
Posts: 122
Location: Ireland

View user's profile Send private message

PostPosted: Wed Jan 09, 2008 3:30 pm     Reply with quote

Thanks for your answer,

Sorry, I've forgot to say that I'm using PCD which is a 16bits compiler.
In the "PCDReferenceManual" it's written that an int is 16bits large.

I've tried to change
Code:
unsigned int   PLLDIV:9;

by
Code:
unsigned int16   PLLDIV:9;

but I still have the same error message Sad

Do you have another idea to correct my code?

Thanks,
Franck.
Guest_7068
Guest







PostPosted: Wed Jan 09, 2008 7:38 pm     Reply with quote

It looks like the compiler is only supporting bit fields with a width of 8, so a the following code will compile:

Code:

typedef struct
{
   unsigned int8  PLLDIV:8;
   unsigned int1   b9:1;
   .....
   ...


You can ask CCS if this is a limitation. As a workaround, you can split the value as 8 bits and 1 top bit (9th bit).
Franck26



Joined: 29 Dec 2007
Posts: 122
Location: Ireland

View user's profile Send private message

PostPosted: Thu Jan 10, 2008 10:07 am     Reply with quote

Thanks,

I will ask to CCS, but a limitation of 8 bits for a 16 bits compiler is quite strange for me...

I will use the workaround till I have an answer from CCS.

Thanks,
Franck.
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