- Code: Select all
#define CLKDIV CLKDIV
extern volatile uint16_t CLKDIV __attribute__((__sfr__));
__extension__ typedef struct tagCLKDIVBITS {
union {
struct {
uint16_t :5;
uint16_t PLLEN:1;
uint16_t :2;
uint16_t RCDIV:3;
uint16_t DOZEN:1;
uint16_t DOZE:3;
uint16_t ROI:1;
};
struct {
uint16_t :8;
uint16_t RCDIV0:1;
uint16_t RCDIV1:1;
uint16_t RCDIV2:1;
uint16_t :1;
uint16_t DOZE0:1;
uint16_t DOZE1:1;
uint16_t DOZE2:1;
};
};
} CLKDIVBITS;
extern volatile CLKDIVBITS CLKDIVbits __attribute__((__sfr__));
I can translate the basic structure part...something like this:
- Code: Select all
Structure CLKDIVBITS
dim value as ushort
dim PLLEN as value.5
dim RCDIV0 as value.8
dim RCDIV1 as value.9
dim RCDIV2 as value.10
dim DOZEN as value.11
dim DOZE0 as value.12
dim DOZE1 as value.13
dim DOZE2 as value.14
dim ROI as value.15
end structure
dim CLKDIVbits as CLKDIVBITS
But how do I 'Union' in the 3-bit values (0-7) for the DOZE and RCDIV so I can do either:
- Code: Select all
CLKDIVbits.RCDIV = 3
or individually as:
- Code: Select all
CLKDIVbits.RCDIV0 = 1
CLKDIVbits.RCDIV1 = 1
CLKDIVbits.RCDIV2 = 0
Obviously this would be applicable to many SFR's so I'm trying to get a grasp on the concept before I proceed...
Thanks,
Jerry