AnsweredAssumed Answered

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

Question asked by Petter Österlund on Jan 14, 2020
Latest reply on Jan 23, 2020 by Aldo Gutierrez

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);

Outcomes