Arm Mbed OS support forum

i.MX RT1050 EVKB Unable to set LPUART to 460800 baudrate

(Edit: After changing serial clock source, I can get baud rate set to 460800. I think the issue has to do with my TTL-RS232 converter board not supporting 460800.)

I’m using an i.MX RT1050 EVKB eval board running Mbed OS 6. I’m trying to set LPUART3 to 460800 baud. However this fails. I can set the baud to anything below that speed. For example, 230400 works great.

Mbed OS 6 calls it’s own function serial_baud() which in turn calls an NXP DRIVER function called
LPUART_SetBaudRate() with a serial clock rate of 24000000 that is defined in fsl_lpuart.c.

LPUART_SetBaudRate() returns kStatus_LPUART_BaudrateNotSupport on baud rate 460800.

If I change the serial clock setup so that the serial clock rate is 80000000 by doing the following:

void serial_setup_clock(void)
    /* Configure UART divider to default */
    //CLOCK_SetMux(kCLOCK_UartMux, 1); /* Set UART source to OSC 24M */
    CLOCK_SetMux(kCLOCK_UartMux, 0);
    CLOCK_SetDiv(kCLOCK_UartDiv, 0); /* Set UART divider to 1 */

Then LPUART_SetBaudRate() succeeds. However, this only allows me to properly receive serial data at 460800 baud, but I can’t send data at that rate.

Notice in the above code Mbed OS is calling an NXP fsl_clock_config.c function
CLOCKSetMux(kCLOCK_UartMux, 0) which gives a uart clock rate of 80000000.

Any help on this would be greatly appreciated.

if you look in fsl_lpuart.c, I see that LPUART_SetBaudRate() returns not supported when the actual baud rate is more than 3 percent in error from your desired baud rate.
It looks to me like you might want to run LPUART_SetBaudRate() under a debugger so you can see the osr value used. Could turn out that you need more than 80MHz clock to get the baud rate you want with under 3 percent error.

1 Like

Thank you for your reply. I really appreciate you taking the time.

Using the 80MHz clock I was able to set the baud rate to 460800.

I instrumented the Mbed OS serial API code so I know the baudrate is being set to 460800.

void serial_baud(serial_t *obj, int baudrate)
    status_t result;
    uint32_t serial_clock;
    serial_clock = serial_get_clock();
    printf("\nSetting baudrate: %d Serial Clock= %d\n", baudrate, serial_clock);
    result = LPUART_SetBaudRate(uart_addrs[obj->index], (uint32_t)baudrate, serial_get_clock());

    printf("Result: %s\n", (result == kStatus_LPUART_BaudrateNotSupport ) ? "FAILED" : "SUCCESS");

Running my code with the 80MHz clock I get the following output:

Setting baudrate: 460800 Serial Clock= 80000000

The issue is with the TTL to RS232 converter that I’m using. It’s limited to 250k which clearly won’t work for 460800. I need to use a different TTL to RS232 chip that is capable of 1Mb baud rates and I should be off to the races.


And it seems rather dubious that serial_baud() doesn’t return a value indicating success or failure.