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.

MSP432 Interrupt Flags

Hi All,

What is the difference between UCTXIFG and UCTXCPTIFG flags?

What flag is more suited for multibyte transmit procedure? (using the interrupt)

Kind regards,

Andrei Zinenko

  • Andrei,

    the USCI module has two places were it holds a byte - these are:

    • the TX buffer UCxxTXBUF
    • the shift-register of the USCI state-machine

    The shift-register holds the byte that is currently transmitted - it's bits are shifted to the output of the processor's pin.

    The TX buffer holds the byte that will be transmitted next. If there isn't a currently running transmission, then the byte you have copied to the TX buffer is immediately forwarded to the shift register and the TX buffer is free again. You do not have access to the shift register, only to the TX buffer.

    So which flag is more suited?

    UCTXIFG is set when the TX buffer is empty and ready to fetch the next byte that will be transmitted after the current one has been completely shifted out (if there is one). So when working with UCTXIFG you can achieve a transmission without any delay in between the single bytes, which leads to a faster transmission. While one byte is currently transmitted, the next one already waits to be transmitted immediately after the other one.

    UCTXCPTIFG signals that the shift register is empty and the TX buffer is empty as well. That means the transmission has completed.

    This often is a trap for beginners - you set chip select of your slave low, transmit a byte (or more) and then (or after the last byte) wait for UCTXIFG to be set, thinking that the transmission is complete and therefore set chip select high again. But a set UCTXIFG does not mean your transmission has finished. It just tells you that there is an empty TX buffer. So setting chip select high in this case would interrupt the byte that is still in the shift register and has not been transmitted completely yet.

    When triggering on UCTXCPTIFG this won't happen because it is set when everything is shifted out and therefore complete.

    So what to to? When sending multiple bytes, use UCTXIFG for all bytes except the last one. For the last one use UCTXCPTIFG and then disable chip select. Of course you also can use UCTXCPTIFG for both, but then you waste some time - you would not use the advantage of having one byte in the pipeline already (depends on the application if that is a problem, or not).

    Dennis

  • Thank you, Dennis
    Andrei

**Attention** This is a public forum