This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/MSP430AFE221: New to msp430, coding, Plz help

Part Number: MSP430AFE221


Tool/software: TI C/C++ Compiler

I am new to msp 430 programming. I was going through source code, where i found this line of code.

  while (!(UC1IFG&UCA1TXIFG));

Here, UC1IFG is register and UCA1TXIFG is a single bit. How can we perform and operation.

  • UC1IFG is a register and UCA1TXIFG is a bit. The instructions performs a loop as long as UCA1TXIFG is not set in UC1IFG or in other words: It waits until UCA1TXIFG gets set. When this bit is set, the transmit buffer is ready to accept the next byte. So this instruction simply waits until you can place another byte into the transmit buffer. This is necessary because otherwise you would overwrite the existing byte in the buffer. Instead of polling you can also generate an interrupt when UCA1TXIFG becomes set. In the ISR you can then copy the next byte to the transmit buffer. The while loop of course generates a short pause of your program flow, but this does not mean that you cannot do it this way - it depends on the application.

**Attention** This is a public forum