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.

MSPM0L1304: How to print text and ints/floats out of uart to a app like hyper terminal

Part Number: MSPM0L1304
Other Parts Discussed in Thread: SYSCONFIG

I am using the MSPM0-1304 and I want to know how to print out to the uart using the tx out pin PA23. I am trying to print it out to hyper terminal or an application similar to that. What I want to print out is strings and number values that can be any number. I am using Code Composure Studio Theia.

Thank you

  • Have you tried the UARTEcho example? That can get you started.

    I have created a simple string printing functionality that uses the interrupts

    You can use sprintf() to create your string - unlike the MSP430's it appears that the MSPM0's have full printf support for floats from the get go.

    I use a simple SysTick Timer for the delay, you could probably just waste some cycles.

    volatile int TXChar = -1;
    char TXData[64];
    void StartSerialTX(char *str) {
    
      while (TXChar != -1) {
        // wait for previous tx to finish
        Delay(10);
      }
    
      strcpy(TXData, str);
    
      TXChar = 0;
    
      DL_UART_Main_transmitData(UART_0_INST, TXData[TXChar++]);
    }

    void UART_0_INST_IRQHandler(void) {
      switch (DL_UART_Main_getPendingInterrupt(UART_0_INST)) {
    
      case DL_UART_MAIN_IIDX_RX:
        RXdata = DL_UART_Main_receiveData(UART_0_INST);
        // DL_UART_Main_transmitData(UART_0_INST, RXdata);
        break;
    
      case DL_UART_MAIN_IIDX_TX:
        if (TXData[TXChar] != '\0') {
          DL_UART_Main_transmitData(UART_0_INST, TXData[TXChar++]);
        } else {
          TXChar = -1;
        }
    
        break;
    
      default:
        break;
      }
    }

  • When I use the echo example it looks like I might be getting the data and printing it back out, I'm not sure how to put the \n in the "gEchoData' that they use.

    For this example code you sent, how would I use "StartSerialTX"?

  • For example if I want to print out "g_HEATERNTC = 2011"

  • Call it with your string.

    char buf = "g_HEATERNTC = 2011";

    StartSerialTX(buf);

  • Okay, and how are you setting up the delay? Are you using systick in sysconfig?

  • Also, it looks like is aborting right after I press the start/continue button in the debugger

  • Yes, I am using Systick in the sysconfig with a little glue to create an Arduino like Millis().

    you can probably just use

    delay_cycles(10000);

    or something.

    I have no idea why it is crashing, can you post your code?

  • #include "ti_msp_dl_config.h"
    #include "string.h"
    
    volatile uint8_t gEchoData = 0;
    volatile int TXChar = -1;
    char TXData[64];
    
    void StartSerialTX(char *str) {
    
      while (TXChar != -1) {
        // wait for previous tx to finish
        delay_cycles(10000);
      }
    
      strcpy(TXData, str);
    
      TXChar = 0;
    
      DL_UART_Main_transmitData(UART_0_INST, TXData[TXChar++]);
    }
    
    int main(void)
    {
        SYSCFG_DL_init();
    
        NVIC_ClearPendingIRQ(UART_0_INST_INT_IRQN);
        NVIC_EnableIRQ(UART_0_INST_INT_IRQN);
        DL_SYSCTL_enableSleepOnExit();
    
        char *buf = "g_HEATERNTC = 2011";
    
        StartSerialTX(buf);
    }
    
    
    
    void UART_0_INST_IRQHandler(void)
    {
        switch (DL_UART_Main_getPendingInterrupt(UART_0_INST)) {
            case DL_UART_MAIN_IIDX_RX:
                gEchoData = DL_UART_Main_receiveData(UART_0_INST);
                break;
            case DL_UART_MAIN_IIDX_TX:
                if (TXData[TXChar] != '\0') {
                    DL_UART_Main_transmitData(UART_0_INST, TXData[TXChar++]);
                } else {
                    TXChar = -1;
                }
                break;
    
            default:
                break;
        }
    }

  • I have to try it tomorrow, but you don't want sleep on exit, since you want main to run.

  • There are several things going on here.

    One is that you need to make sure that the UART transmit interrupt is active in syscfg.

    The other is that the way the program is written it falls off teh end of main() and gets trapped and halted by the debugger before all the characters are sent. I do get a "g". Simply hit continue and the other characters will get sent.

    To really fix it put in an endless loop so that main() never exits:

    while (1) {
        __WFI();
      }

  • Hi, 

    Add more information to int/float support using tinyprintf from Github:GitHub - mpaland/printf

    3554.printf_to_uart_LP_MSPM0G3507_nortos_ticlang.zip

    Demo code here.

    Regards,

    Helic