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.

MSPM0G3107: How to get value from UART

Part Number: MSPM0G3107
Other Parts Discussed in Thread: MSPM0G3507

Hi guys,

I met some issues with UART with LP-MSPM0G3507 evaluation board.

To make it simple, I use the example code of uart_echo_interrupts_standby to explain my issue.

I modified uart_echo_interrupts_standby a little, to echo the received value+1. e.g. user input "1" and received "2" via UART. This part works well.

The problem is I cannot use the received data in main() function.

The variable "volatile uint8_t gEchoData " stores the received data via UART. I use a new variable gEchoData2 just to show the issue.

At line 14 gEchoData2 =gEchoData;

Now after I input any data from PC side, I can see echo, but both gEchoData2  and gEchoData are always zero, they were not changed.

The stranger thing is, if I set a breakpoint at Line 14, at beginning after Restart , the program always stop there as expected.

After I disabled the breakpoint and inputted some thing from PC, then enable the breakpoint again, but the program will not stop there any more. And, as mentioned above, the variables of  gEchoData2 and gEchoData keep as zero. Meanwhile the echo is still working. That means the interrupt is good, but just cannot return to main(). 

I tried to lower the optimization level, but didn't help.

Thanks for any comments.

Leo

#include "ti_msp_dl_config.h"

volatile uint8_t gEchoData = 0;
uint8_t gEchoData2 = 0;
int main(void)
{
    SYSCFG_DL_init();

    NVIC_ClearPendingIRQ(UART_0_INST_INT_IRQN);
    NVIC_EnableIRQ(UART_0_INST_INT_IRQN);
    DL_SYSCTL_enableSleepOnExit();

    while (1) {
        gEchoData2 =gEchoData;
        //__WFI();
    }
}

void UART_0_INST_IRQHandler(void)
{
    switch (DL_UART_Main_getPendingInterrupt(UART_0_INST)) {
        case DL_UART_MAIN_IIDX_RX:
            DL_GPIO_togglePins(GPIO_LEDS_PORT,
                GPIO_LEDS_USER_LED_1_PIN | GPIO_LEDS_USER_TEST_PIN);
            gEchoData = DL_UART_Main_receiveData(UART_0_INST);
            gEchoData++;
            DL_UART_Main_transmitData(UART_0_INST, gEchoData);
            break;
        default:
            break;
    }
}