On Fri, Mar 07, 2003 at 11:35:02AM -0500, Mark Stokes wrote:
> I have a macro:
> #define SPITXWAIT   while ( !( IFG1 & UTXIFG0 ) );  // Wait for the TX 
> That is expanding to this:
> 
>     SPITXWAIT;                          // USART0 TX buffer ready?
>     1994:     c2 93 02 00             cmp.b   #0,     &0x0002 
>     1998:     fd 37                   jge     $-4     ;abs dst addr
> 0x1994
> 
> Even though this is seeminging to work, why is UTXIFG0 being expanded to
> "#0" instead of "0x80" as it should be.  Here is the macro definitions
> in the header file:
> #define UTXIFG0             (1<<7)

It is working because anything greater or equal 0x0 has bit 7 clear,
if something is less than 0, it will have bit 7 set. Maybe it is an
optimization feature, or something...

> Try as I might, I cannot get the cmp.b to compare w/ 0x80.  It seems
> stuck on only comparing Zero with IFG1.  This also happens when I use
> something else, like U0TCTL.  Or if I use this macro definition:
> #define SPITXWAIT   while ( !( IFG1 & 0x80 ) );  // Wait for the TX 
> 
> Any ideas?

Maybe you should try to define everything with a cast to (unsigned char).

Try to define UTXIFG0 as:

#define UTXIFG0             ((unsigned char) 1<<7)

And IFG1 in the same way.

Reply via email to