|
|
View previous topic :: View next topic |
Author |
Message |
Robert Carter Guest
|
Structures |
Posted: Fri Apr 18, 2003 12:44 pm |
|
|
I am trying to construct a 24-bit bit number, based on values of several variables of varying lengths, to be shifted out on an I/O pin. I get a "number out of range" error when compiling the following code. Is it possible to implement this type of structure? The Reference manual indicate only 8-bit values are allowed, but I have seen others using flot values.
struct RF_N
{
int8 RF_CTL_WORD : 3;
int16 C_WORD : 11;
int8 B_WORD : 2;
int8 A_WORD : 2;
int8 FRAC_CNTR : 4;
int8 CTL : 2;
} PLL_RF_N;
___________________________
This message was ported from CCS's old forum
Original Post ID: 13792 |
|
|
R.J.Hamlett Guest
|
Re: Structures |
Posted: Fri Apr 18, 2003 1:36 pm |
|
|
:=I am trying to construct a 24-bit bit number, based on values of several variables of varying lengths, to be shifted out on an I/O pin. I get a "number out of range" error when compiling the following code. Is it possible to implement this type of structure? The Reference manual indicate only 8-bit values are allowed, but I have seen others using flot values.
:=
:=struct RF_N
:= {
:= int8 RF_CTL_WORD : 3;
:= int16 C_WORD : 11;
:= int8 B_WORD : 2;
:= int8 A_WORD : 2;
:= int8 FRAC_CNTR : 4;
:= int8 CTL : 2;
:= } PLL_RF_N;
You can use float values, but not with the length field descriptor. However you may be able to get what you require, by nesting a defintion, though how the actual data will be stored then falls into question. Unfortunately, at present, the bits will not wrap over into multiple bytes, meaning there will be 'gaps' in the data stored.
So you could define the variable with:
struct C_W {
int8 lo : 3;
int8 hi;
};
struct RF_N
{
int8 RF_CTL_WORD : 3;
struct C_W C_WORD;
int8 B_WORD : 2;
int8 A_WORD : 2;
int8 FRAC_CNTR : 4;
int8 CTL : 2;
} PLL_RF_N;
But this will occupy five bytes of memory, not four bytes.
Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 13794 |
|
|
|
|
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
|