Joe Haas

"dbug" macro problems

Discussion created by Joe Haas on Mar 7, 2006
Latest reply on Mar 13, 2006 by CrasyCat
I am trying to port dbug to a 5407 board and have run into a snag regarding macros.
 
The following snippet is representative of the macros included in my dbug source:
 
/**********************************************************************/
/*  Macro for computing address of on-chip peripheral registers       */
/**********************************************************************/
 
#define Mcf5407_addr(IMMP,OFFSET)   ((void *)&((uint8 *)IMMP)[OFFSET])
/**********************************************************************/
/*  Macros for accessing the on-chip I/O resources                    */
/**********************************************************************/
 
#define Mcf5407_iord(IMMP,OFFSET,SIZE)      \
   *(volatile uint ## SIZE *)(Mcf5407_addr(IMMP,OFFSET))
#define Mcf5407_iowr(IMMP,OFFSET,SIZE,DATA)  \
   *(volatile uint ## SIZE *)(Mcf5407_addr(IMMP,OFFSET)) = (DATA)
//
//
//
#define MCF5407_CS_CSAR0        (0x0080)
#define MCF5407_WR_CS_CSAR0(IMMP,DATA)  \
   Mcf5407_iowr(IMMP,MCF5407_CS_CSAR0,16,DATA)
However, when I compile and examine the object code, I notice that the addressed offsets are 2x too big (the compiler is using (d16,Ax) addressing where Ax = the MBAR address in this case).  For example, the MCF5407_CS_CSAR0 offset compiles as 0x0100 instead of 0x0080.  I'm new to C macros and I'm stumped as to what is wrong.
 
Note that these macros are as-is from the dbug source that I aquired.
 
Thanks,
 
Joe
 

Outcomes