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.

MSP432E401Y: Simultaneous UART TX/RX

Part Number: MSP432E401Y

#define RECLEN 4
int32_t rec[RECLEN] , ite = 0;
bool chkUARTcmd = false;

void UART6_IRQHandler(void)
{
    uint32_t ui32Status;

    ui32Status = MAP_UARTIntStatus(UART6_BASE, true);

    MAP_UARTIntClear(UART6_BASE, ui32Status);
    
    if(ui32Status & UART_INT_RX){
        while(MAP_UARTCharsAvail(UART6_BASE)  )
        {
            rec[ite++] = MAP_UARTCharGetNonBlocking(UART6_BASE);
            if (RECLEN == ite)
            {
                chkUARTcmd = true;
                ite = 0;
            }
        }
    }
}
void UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
    while(ui32Count--)
    {
        MAP_UARTCharPutNonBlocking(UART6_BASE, *pui8Buffer++);
    }
}
int main(void)
{
    initUART(); //Initialize UART settings, content omitted.
    
    while(1)
    {
        if(chkUARTcmd){
            UARTSend((uint8_t *)"ABCDEFGH", 8);
            chkUARTcmd = false;
        }
    }
}

Hi, We need to useMSP432E401Y UART to receive commands and send back an acknowledgment of the received instructions. However, we've identified that the UART RX and TX share the same register. In the provided code, when writing to the RX buffer, it gets interfered with by the TX process, resulting in the RX buffer being incorrectly written with TX transmission data. How can we resolve this issue? How should we implement simultaneous TX/RX?

  • Hi Jia-Yu,

      UART has separate TX and RX buffers. It is supposed to read from the RX buffer when you call MAP_UARTCharGetNonBlocking. When you call MAP_UARTCharPutNonBlocking, it will put the data on the TX buffer. However, I will suggest you use MAP_UARTCharGet instead of MAP_UARTCharGetNonBlocking and MAP_UARTCharPut instead of MAP_UARTCharPutNonBlocking to see if it makes a difference. 

      Also bear in mind that UART is full-duplex. In your current code, you are in a while loop that constantly send data but you only receive data when there is a RX interrupt. This can create out of sync. You should consider in your UART6_IRQHandler to send your data while receiving. Please refer to the example .