i.MX8 M4 UART baudrate not correctly set for some values; SDK 2.6 and 2.7

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX8 M4 UART baudrate not correctly set for some values; SDK 2.6 and 2.7

817 Views
osterlund_pette
Contributor I

I have i.MX8MM EVK and using the MCUXpresso generated SDK for the M4 core. I have default clock tree where UART clock is 80 MHz.

When I set baudrate 4000000 I get correct actual baudrate. But another for me interresting baudrate, 3636363, I get 8000000 MHz which is well above theoretical max; 80000000/16 = 5000000. In fact the selected UBMR/UBIR is < 1 which is not valid. For 3636363 baud the lowest best values are bestUBMR=6 bestUBIR=4. Trying a lower value shows 3636300 gives the expected baudrate (but with larger UBMR and UBIR than the lowest most optimal values).

There are several such miscalculated baudrates. I just give this one as example. This is unfortunate.

  1. 3636363 -> Actual baud rate = 8000000 : 80000000/(16 * (44641+1) / (64934+1)
  2. 3636362 -> 8000000
  3. 3636331 -> 8000000
  4. 3636315 -> 7272727
  5. 3636307 -> 8000000
  6. 3636303 -> 7272727
  7. 3636301 -> 7272727
  8. 3636300 -> Actual baud rate = 3636363 : 80000000/(16 * (49999+1) / (36362+1)

  UART_GetDefaultConfig(&config);
  config.baudRate_Bps = RTIO_UART_BAUDRATE;
  config.rxFifoWatermark = 16;
  config.txFifoWatermark = 4;
  config.enableTx     = true;
  config.enableRx     = true;
  res = UART_Init(RTIO_UART, &config, RTIO_UART_CLK_FREQ);
  int srcClock_Hz = RTIO_UART_CLK_FREQ;
  PRINTF("Actual baud rate = %d : %d/(16 * (%d+1) / (%d+1)\n",
         (int) (srcClock_Hz/((uint64_t)16 * (RTIO_UART->UBMR + 1)/(RTIO_UART->UBIR+1))),
         srcClock_Hz, RTIO_UART->UBMR, RTIO_UART->UBIR);
0 Kudos
3 Replies

706 Views
osterlund_pette
Contributor I

Thank you, but UART_Init() returns no error (checked in my code just below). The baudrate is supported and as I describe lowering the requested value a little bit gives me the exact baudrate I originally requested and wanted - and it does work in real life too since I can communicate with an STM32 set to the wanted baudrate. The cause of the error is incorrect implementation in UART_Init(). At the end of UART_Init() where it is checked if baudrate error < 3% it says OK even though it is completely off - hence UART_Init() returns OK.

Note: the reason I try what seems like odd baudrates is that I'm minimizing the baudrate error between i.M8 and an STM32.

0 Kudos

706 Views
AldoG
NXP TechSupport
NXP TechSupport

Hi,

Thank you for your answer, I see I need to do some test on it and report this to sw team, if I get something I'll let you know.

Thank you for your report,
Regards,
Aldo.

0 Kudos

705 Views
AldoG
NXP TechSupport
NXP TechSupport

Hello,

 

This odd behavior may be due that the Baudrate is not supported in the current clock source, so the registers are not set correctly, please check the return value from the UART_Init API.

 

Hope this helps,

Regards,

Aldo.

0 Kudos