I know I was a bit terse in my last email (below) but I was rushing
out to an appointment. Anyway, IAR defines registers like this:
/************************************/
__no_init volatile union
{
unsigned char P1OUT; /* Port 1 Output */
struct
{
unsigned char P1OUT_0 : 1;
unsigned char P1OUT_1 : 1;
unsigned char P1OUT_2 : 1;
unsigned char P1OUT_3 : 1;
unsigned char P1OUT_4 : 1;
unsigned char P1OUT_5 : 1;
unsigned char P1OUT_6 : 1;
unsigned char P1OUT_7 : 1;
} P1OUT_bit;
} @ 0x0021; /* Non-standard syntax (pragma) here... */
__no_init volatile union
{
unsigned short TBCCTL3; /* Timer B Capture/Compare Control 3 */
struct
{
unsigned short CCIFG : 1; /* Capture/compare interrupt flag */
unsigned short COV : 1; /* Capture/compare overflow flag */
unsigned short OUT : 1; /* PWM Output signal if output mode 0 */
unsigned short CCI : 1; /* Capture input signal (read) */
unsigned short CCIE : 1; /* Capture/compare interrupt enable */
unsigned short OUTMOD : 3; /* Output mode 0 */
unsigned short CAP : 1; /* Capture mode: 1 /Compare mode : 0 */
unsigned short CLLD : 2; /* Compare latch load source */
unsigned short SCS : 1; /* Capture sychronize */
unsigned short CCIS : 2; /* Capture input select */
unsigned short CM : 2; /* Capture mode */
} TBCCTL3_bit;
} @ 0x0188; /* Non-standard syntax (pragma) here... */
/************************************/
So that I can write code like this:
#define RED_LED P1OUT_bit.P1OUT_7
#define GREEN_LED P1OUT_bit.P1OUT_6
void main (void)
{
RED_LED = 1;
GREEN_LED = 0;
}
The advantage here is that it's impossible to use a bitfield definition
from one register on a different, incorrect register.
So given the mspgcc structure definition below, does anyone know how
to use the structure in a manner similar to IAR? I know how structures
work but I don't see how this relates to the way the register address
is defined:
#define TBCCTL3_ 0x0188 /* Timer B Capture/Compare Control 3 */
sfrw(TBCCTL3,TBCCTL3_);
- Dan Miner
> -----Original Message-----
> From: Dan Miner
> Sent: Tuesday, May 03, 2005 2:54 PM
>
> In many of the register definition include files, there are
> useful bitfield definitions. For example, from timerb.h:
>
> typedef struct {
> volatile unsigned
> ccifg:1,
> cov:1,
> out:1,
> cci:1,
> ccie:1,
> outmod:3,
> cap:1,
> clld:2,
> scs:1,
> ccis:2,
> cm:2;
> } __attribute__ ((packed)) tbcctl_t;
>
> Can someone please point me to documentation or an example of
> how to use these? I'm trying to port some IAR code to mspgcc
> which uses their version of register bitfields.
>
> I'm using the Win32 package from 20050422.
>
> - Dan Miner