View previous topic :: View next topic |
Author |
Message |
Franck26
Joined: 29 Dec 2007 Posts: 122 Location: Ireland
|
typedef struct -> Nb of bits out of range |
Posted: Wed Jan 09, 2008 2:25 pm |
|
|
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
|
|
Posted: Wed Jan 09, 2008 3:13 pm |
|
|
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
|
|
Posted: Wed Jan 09, 2008 3:30 pm |
|
|
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
Do you have another idea to correct my code?
Thanks,
Franck. |
|
|
Guest_7068 Guest
|
|
Posted: Wed Jan 09, 2008 7:38 pm |
|
|
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
|
|
Posted: Thu Jan 10, 2008 10:07 am |
|
|
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. |
|
|
|