This kind of definition serves a double purpose:
First, you'll get a void value TA0CTL_ which can be used in pojnter manipulations, as data value or whatever. Second, you'll get a volatile unsigned int variable located at the TA0CTL_ address. By using the sfrw/sfrb macros, the compiler knows that this is a byte/word variable and shall be accessed using byte/word access. It also tells the compiler that this variable is volatile, meaning that its content might change at any time without notice, so it mus tbe addressed directly each time it is used and not buffered in a processor register etc. Just assigning TA0CTL to 0x160 would require you to cast the value you assign to it to an unsigned int and the value to an unsigne int * each time you use it. One COULD use 0x0160 directly in the sfrw macro to avoid clobbering the namespace with the named values. But if you really need the address itself, you had to extract it by '(void *)(&TA0CTL)'. JMGross ----- Ursprüngliche Nachricht ----- Von: Anthony L An: [email protected] Gesendet am: 05 Apr 2009 16:43:18 Betreff: [Mspgcc-users] sfrw macro Hi All! Could someone please tell me what the purpose of the sfrw macro is? For example: #define TA0CTL_ 0x0160 sfrw (TA0CTL,TA0CTL_) What would be the difference to defining TA0CTL directly to 0x0160 ? Thanks Anthony
