CONTEXT:
The Freescale Application Note AN2616, "Getting Started with HCS08 and CodeWarrior Using C", section 6.6, recommends defining a register via a structure, as in this example:
/*** DBGC - Debug Control Register ***/
typedef union {
byte Byte;
struct {
byte RWBEN :1; /* Enable R/W for Comparator B */
byte RWB :1; /* R/W Comparison Value for Comparator B */
byte RWAEN :1; /* Enable R/W for Comparator A */
byte RWA :1; /* R/W Comparison Value for Comparator A */
byte BRKEN :1; /* Break Enable */
byte TAG :1; /* Tag/Force Select */
byte ARM :1; /* Arm Control */
byte DBGEN :1; /* Debug Module Enable */
} Bits;
} DBGCSTR;
extern volatile DBGCSTR _DBGC @0x00001816;
using these data types:
/* Types definition */
typedef unsigned char byte;
typedef unsigned int word;
typedef unsigned long dword;
typedef unsigned long dlong[2];
To access the bits of DBGC, you can write things like
DBGC.Bits.RWB = 1; /*Set RWB bit of DBGC */
DBGC.Bits.RWB = 0; /*Clear RWB bit of DBGC */
Note that this avoids the use of a pointer to access DBGC by telling the compiler where it is located.
PROBLEM:
This may work fine for the CodeWarrior HCS08 compiler but not for either the CodeWarrior Coldfire or the Microsoft Visual Studio 2005 compiler. Both are unhappy about dealing with a statement like
extern volatile DBGCSTR _DBGC @0x00001816;
which is supposed to declare that DBGC is at location 0x00001816.
QUESTION:
How can I achieve the same effect with the CodeWarrior and the Microsoft Visual Studio compilers? I.e., how can I tell these compilers what address to assign to a variable?
Thanks,
Richard