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.

MSP432P401R: Transmit over UART

Part Number: MSP432P401R

I am trying to send some chars over the UART. When I run my program without debugger only last character of message is arrived on PC but if I do that step by step all chars are on target. My code is very simple:

void WiFiPrint(char *msg)
{
    uint32_t i;
    status = 0;
   
    memset(niz,0,sizeof(uint8_t)*15);

    for(i=0; i < strlen(msg); i++)
    {

        niz[i] = msg[i];
        while((UCA2IFG & EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG));
        MAP_UART_transmitData(EUSCI_A2_BASE, msg[i]);
    }

}

void EUSCIA2_IRQHandler  (void)
{
    uint32_t status = MAP_UART_getEnabledInterruptStatus(EUSCI_A2_BASE);
    MAP_UART_clearInterruptFlag(EUSCI_A2_BASE, status);

    if (!status)
        return;

    if (status & EUSCI_A_UART_TRANSMIT_INTERRUPT)
    {
        __no_operation();
     }

}

After loop execution in both way array niz iz filled with all chars from message so loop was executed.

Where did I go wrong?

Best regards,

Djordje Radovanovic

  • > while((UCA2IFG & EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG));

    This test is backwards, so unless you're stepping through it you'll overrun the transmitter. Try:

    > while(!(UCA2IFG & EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG));

    If you're using this code, you shouldn't enable the Transmit Interrupt.