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.

Difference between TXCPTIFG and TXIFG flags in UART (MSP432)

I'm not being able to understand the difference between TXCPTIFG and TXIFG  in the UCAxIFG register from UART of MSP432. I am trying to use UART in the UART Mode, just  to send characters to a PC, but both are set together when transmit interrupt occurs. The User Guide explanation is:

TXCPTIFG  - Transmit ready interrupt enable. UCTXRDYIFG is set when the entire byte in the internal shift register got shifted out and UCAxTXBUF is empty.

TXIFG  - Transmit interrupt flag. UCTXIFG is set when UCAxTXBUF empty.

If the user guide is correct, both will set when UCAxTXBUF is empty after transmission of a character. But whats the real difference?

Maybe, the right question should be: Whats the difference between UART_TRANSMIT_INTERRUPT and UART_TRANSMIT_COMPLETE_INTERRUPT?


I only enabled the EUSCI_A_UART_TRANSMIT_INTERRUPT, as can be seen in the code snippet bellow.

/* Enabling interrupts */
MAP_Interrupt_enableMaster();// MASTER
MAP_Interrupt_enableInterrupt(INT_EUSCIA0); // NVIC
MAP_UART_enableInterrupt(EUSCI_A0_MODULE, EUSCI_A_UART_TRANSMIT_INTERRUPT);//PERIP.

If I'm not mistaken the TXCPTIFG flag are triggering EUSCI_A_UART_TRANSMIT_INTERRUPT. I belived that only TXIFG  could do it, while TXCPTIFG should trigger UART_TRANSMIT_COMPLETE_INTERRUPT,  if that interrupt source is activated, but isn't my case.

Moreover, how to clear TXCPTIFG using driverlib? My first impression is that driverlib allows only clear the flag TXIFG. I used the the following code:

uint32_t status = MAP_UART_getEnabledInterruptStatus(EUSCI_A0_MODULE);
MAP_UART_clearInterruptFlag(EUSCI_A0_MODULE, status);

but only TXIFG is cleared.

Thanks!

  • Hi Otavio,

    UCTXCPTIFG is set when the complete UART byte in the internal shift register including the STOP bit gets shifted out. Since applications typically only care about the status of UCAxTXBUF so that they can send the next byte or stop communication and are unconcerned about when the STOP bit is sent, since it only indicates the full completion of a UART transmit, it follows that UCTXIFG is used a lot more hence why it is mentioned so much in the User's Guide and has a higher priority.

    MAP_UART_enableInterrupt(EUSCI_A0_MODULE, EUSCI_A_UART_TRANSMIT_INTERRUPT); will only enable the UCTXIFG to cause an interrupt but the UCTXCPTIFG can still be set without resulting in any action by the CPU.

    As to why only UCTXIFG is cleared by MAP_UART_clearInterruptFlag(EUSCI_A0_MODULE, status); this is due to the fact that uint32_t status = MAP_UART_getEnabledInterruptStatus(EUSCI_A0_MODULE); will only return the value of the IFG that caused the interrupt to occur, in this case being UCTXIFG since it does have the higher priority, will be serviced faster because it does not wait on the status of the STOP bit, and was the only IFG enabled. If you would like to manually clear UCTXCPTIFG then you could use the command MAP_UART_clearInterruptFlag(EUSCI_A0_MODULE, 0x03); but as initialized UCTXCPTIFG will not result in an interrupt so its status is of no concern.

    Regards,
    Ryan
  • Great explanation! Thanks Ryan.

    Regards,

**Attention** This is a public forum