AnsweredAssumed Answered

Changing UART Baud Rate in FreeRTOS?  Flushing FIFOs

Question asked by Myke Predko on Mar 26, 2020
Latest reply on Apr 3, 2020 by Myke Predko



I'm using the FreeRTOS UART driver (SDK 2.3.1 with a MK22FN1M0Axxx12) for my application and there are cases where I need to change the baud rate of the UART.  There is a workflow where there is the need to change the initial baud rate, change the (Bluetooth) module that it is communicating with to the higher baud rate and then changing back.  


I have tried using the basic UART driver change baud rate:

               , BT_UART_CLK_FREQ);

When I test with "UART_SetBaudRate", I can see the data come out at the new baud rate.  


But when data comes in, it's not received in software.  

  • I've tried doing an "UART_RTOS_DEINIT()" but this failes with a semihost_hardfault.  
  • I've tried doing a second "UART_RTOS_INIT()" but when data comes in, it's not received.  In the application, this would ahve to be done twice 



If I don't try changing the baud rate, UART operations work without any problems with multiple transmits/receives.  


What is the right way to change the baud rate of the UART in FreeRTOS?



2020.03.28 - I'm doing testing on my product and I'm introducing different error conditions - one being to halt processor execution to force an error on the device connected to the FreeRTOS Kinetis device.  When I resume execution followed by communications, I get repeated Hardware Buffer Overruns until I remove power from the Kinetis.  If I take a look at the Refrence Manual, this looks like the UART FIFOs aren't being flushed on reset.  


Is there a way using the FreeRTOS APIs to flush the UART's FIFOs or will I have to manually access the UARTx_CFIFO Flush bits?