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.

MSPM0G3507: Problem to configure uart.

Part Number: MSPM0G3507

Tool/software:

Dear Sir/Madam,

I try to run uart on this controller.

I have two packages One is 28 Pin and second one is 48 Pin.

In both controller uart 3 is running properly, but uart 0 and uart 1 not running properly.

I just try to run echo program on every uart but there is some problem in configuration setting so program not running properly.

I attach the terminal photo in which we try to echo character 'a' but we are not getting return 'a'. 

We are using external Crystal of 16MHz. We have already run other peripherals like LED, alphanumeric Display and other stuff.

Also we share a code for reference which we use to try to run the uart.

void uart_init(UART_Regs *uart, uint32_t baud)
{
uart->CLKSEL = DL_UART_CLOCK_BUSCLK;

DL_UART_disable(uart);
uart->CTL0 = (DL_UART_DIRECTION_TX_RX);
uart->LCRH = (DL_UART_WORD_LENGTH_8_BITS);

uart->CTL0 |= DL_UART_OVERSAMPLING_RATE_16X;

uart->IBRD = 26;
uart->FBRD = 3;
set_baud_rate(uart, baud);

/* Configure Interrupts */
uart->CPU_INT.IMASK = DL_UART_INTERRUPT_RX;

DL_UART_Main_enable(uart);

  if(uart == UART3)
  {
    NVIC_ClearPendingIRQ(UART3_INT_IRQn);
    NVIC_EnableIRQ(UART3_INT_IRQn);
  }

  else if (uart == UART0)
  {
     NVIC_ClearPendingIRQ(UART0_INT_IRQn);
     NVIC_EnableIRQ(UART0_INT_IRQn);
 }
}

This is code we use to test uart.

When we pass uart 3 in this fuction then uart 3 runs properly but when we use any other uart (Ex uart 0 and uart 1).

It is not working properly.

We also just try to transmit the string but there we also get garbage value on terminal.

Please help to rectify the issue.

  • > uart->CLKSEL = DL_UART_CLOCK_BUSCLK;

    BUSCLK is ULPCLK for UART0-2, and is MCLK for UART3 [Ref TRM (SLAU846A) Sec 16.2.1]. ULPCLK is set according to MCLKCFG.UDIV, which defaults to =1, i.e. ULPCLK=MCLK/2 [Ref TRM Table 2-33]. This means that your xBRD values would be different.

    Try setting MCLKCFG.UDIV=0, so ULPCLK=MCLK/1.

    [Edit: Fixed typo.]

  • Hi Trilok,

    Agree with Bruce.

    If you use the default 32MHz (SYSOSC), MCLK will be the same as ULPCLK.

    If you do have configure the MCLK higher than 40MHz (usually with PLL), then the ULPCLK will be MCLK/2.

    B.R.

    Sal

  • Thanks for your reply.

    Can you please share any sample code for uart 0 and uart 1, so we can understand the resolution.

  • See below SDK example project, which use the UART0 to do the communication.

    https://dev.ti.com/tirex/explore/node?node=A__AEDfu0vT-g8KuJe2UMLixw__MSPM0-SDK__a3PaaoK__LATEST 

    You should take care of the BUSCLK of the project: (Open .syscfg file)

    If you set the MCLK=80MHz, and ULPCLK=40MHz. You will find the difference here for UART0-2/UART3.

    [ULPCLK should no more than 40MHz according to datasheet spec.]

    B.R.

    Sal

  • Thank You Sir. 

    I think my problem is resolved.

    I just confirm by running all uart simutaneously.

    Thank you for your support.

  • You are welcome. I will close the thread as the problem solved. Feel free to reply here or file new one if you have further question.

    B.R.

    Sal

  • As an alternative to the .syscfg change, you could use something like:

    >     SYSCTL->SOCLOCK.MCLKCFG &= ~SYSCTL_MCLKCFG_UDIV_MASK; // UDIV=0 -> ULPCLK=MCLK/1

    As Sal points out, you mustn't do this if MCLK>40MHz (but this isn't your case if you're running at 16MHz).