AnsweredAssumed Answered

Question on MC13213 PORT define

Question asked by rui zhou on Mar 13, 2012
Latest reply on Mar 15, 2012 by bigmac

Hello,

 

I am a newer on freescale 8-bit MCU. Now I am in the process of adding 1-wire sensor communication on a Beekit generated project. The one wire is connected with Port A pin0 of MC13213 SRB demo board. While I assign the port which I will use to communicate with 1-wire, I have a question about the definition of the port in mc9s08gb60.h file.

 

For example when define the data register in port A @ 0x00000000, the codes are:

 

/*** PTAD - Port A Data Register; 0x00000000 ***/typedef union {  byte Byte;  struct {    byte PTAD0       :1;      /* Port A Data Register Bit 0 */    byte PTAD1       :1;      /* Port A Data Register Bit 1 */    byte PTAD2       :1;      /* Port A Data Register Bit 2 */    byte PTAD3       :1;      /* Port A Data Register Bit 3 */    byte PTAD4       :1;      /* Port A Data Register Bit 4 */    byte PTAD5       :1;      /* Port A Data Register Bit 5 */    byte PTAD6       :1;      /* Port A Data Register Bit 6 */    byte PTAD7       :1;      /* Port A Data Register Bit 7 */  } Bits;} PTADSTR;extern volatile PTADSTR _PTAD @0x00000000;#define PTAD                            _PTAD.Byte#define PTAD_PTAD0                      _PTAD.Bits.PTAD0#define PTAD_PTAD1                      _PTAD.Bits.PTAD1#define PTAD_PTAD2                      _PTAD.Bits.PTAD2#define PTAD_PTAD3                      _PTAD.Bits.PTAD3#define PTAD_PTAD4                      _PTAD.Bits.PTAD4#define PTAD_PTAD5                      _PTAD.Bits.PTAD5#define PTAD_PTAD6                      _PTAD.Bits.PTAD6#define PTAD_PTAD7                      _PTAD.Bits.PTAD7

 

My question is that the code defined the data register from bit 0 to 7 using PTAD_PTAD0 to PTAD_PTAD7. But it seems all of them are pointing at the same address @ 0x00000000. Why not just define only one data register and use a offset value to find the others? Also, while define the Bits structure, the type for PTAD0 to PTAD7 is in byte type. Is there any reason to define them as byte? Thanks


Outcomes