Be Aware of the Baud Problem

I’m using serial communication in different flavors for my project: with the shell, with OpenSDA USB CDC, to use printf(), and with the Bluetooth module. Processor Expert is a big helper, but as for any software, it is not bug free. And there is a problem with Processor Expert in CodeWarrior for MCU10.3 in respect with Baud settings for a serial interface.

Probing the Bluetooth Module Serial Connection

Probing the Bluetooth Module Serial Connection

The problem is: depending on my clock configuration of the Kinetis-L KL25Z (e.g. FRDM-KL25Z board), the Baud seen on the wires is off by a factor of two.

❗ This problem has been reported and should be fixed in an upcoming update of CodeWarrior. Until then, this post might help you to work around the problem.

I stumbled upon this problem while developing the firmware for a Serial Bluetooth module and the FRDM-KL25Z Freedom board. In some configurations, I was able to communicate properly over SCI/RS-232 with the Bluetooth module, but not in others.

I had the UART configured for 38400 Baud:

38400 Baud

38400 Baud

However, although I knew for a fact that my Bluetooth module is configured to communicate with 38400 Baud, I was not able to connect. Time to probe things with my logic analyzer. And this is what came out:

Garbage in the Logic Analyzer

Garbage in the Logic Analyzer

Configured to analyze the UART traffic using 38400 Baud, the result is just garbage. Luckily I had the idea to use the ‘Autobaud’ function in the analyzer. And voilà:

Autobaud shows 19230 Baud

Autobaud shows 19230 Baud

So what came over the wires was only half of the speed I have configured :-(.

So I doubled the Baud in the component settings to 2*38400=76800 Baud, and now it was working with 34800 Baud:

Working with 38400 Baud

Working with 38400 Baud

Looking at how the Baud clock is generated in the component, showed the cause of the problem: it is using the core clock (as on Kinetis-K) instead of the Bus clock (as it should for Kinetis-L):

Clock Path

Clock Path

So it is dividing from the 48 MHz core clock (instead of the 24 MHz Bus clock). And indeed I have a clock speeds for bus and core in my CPU settings:

Different Core and Bus Clock

Different Core and Bus Clock

This explains why it was working for a different project. In that different project my core and bus clock are set to the same speed :-).

So: to overcome the issue, either use same core and bus clock, or change the baud setting in the component to ‘tune’ to the desired baud.


Processor Expert in the MCU10.3 release is not taking into account that the bus clock divider on L series is dividing down the Core clock, NOT the MCGOUTCLK that would be used on Kinetis K series. In case the Baud is off by this, a workaround is to change the Baud settings in the component to a higher value to produce the correct Baud. Of course, once a fixed Processor Expert comes out, that ‘fix’ has to be reverted.

Another workaround is to use the same bus and core clock speed. But as the bus clock on the Kinetis-L is limited to 24 MHz, that means to run the CPU with 24 MHz instead of the possible 48 MHz.

Different Clock Source for UART’s

On fact I was not aware of until [Victor] posted a comment to this article: the UART0 on the KL25Z has a selectable clock input: See “UART – Unversal Asynchronous Receiver/Transmitter” on page 7: with the SIM_SOPT register a clock source can be selected:

Diagram Connections - Clock Source  (Source: Freescale)

Diagram Connections – Clock Source (Source: Freescale)

And indeed: in CodeWarrior for MCU10.5 I can select the clock source in Processor Expert where I can enter the baud:

Clock Source Selection for UART0

Clock Source Selection for UART0

Happy Bauding 🙂

PS: it is ‘Baud‘, not ‘Baud rate’. ‘Baud’ is the symbol rate, and it already contains the ‘rate’. Sounds like a minor thing, but there is a peer in my office which always points this out, should I ever, ever, ever use the term ‘Baud rate’ ;-). Yes, he is technically 100% correct. Thank you, Marcel :mgreen:

Additional link: What’s the difference between bit rate and baud rate

20 thoughts on “Be Aware of the Baud Problem

  1. I had the same problem last week, uart0 worked fine but uart1 and uart2 had baud rates of 1/2 of the set value in PE. Because Uart0 has significantly different features then uart1 and uart2, I assumed that the different internal dividers were not accounted for in the processor expert.

    Processor expert makes using the peripherals very easy but does not utilize many of the unique features of the peripherals. It also tends to kill the performance with huge software overhead. Many times I use PE to initialize the peripherals but talk to them the “old way” by reading/writing directly to registers for full functionality and performance.



    • Hi Jeff,
      yes, there are always trade offs between speed, size and as well for time to implement things. As for myself I need to support many different processors and microcontrollers, and with this PE makes things a lot easier for me. But of course if you target say just one microcontroller (or a few), it might be worthwile to hand-optimize the functions, or to use other libraries. But as you say: initializing the peripherals and using this as a starting point is something I use very frequently too. In this post case Processor Expert implementation was wrong (and the hardware manual was correct). But I have seen more cases were the reference manual was wrong (or maybe not clear, or misleading), while the Processor Expert generated code was giving me a working piece of software.


  2. Hi!
    I was trying to set the baud for the UART1 but it doesn’t allow values higher than 57600.
    The error reported is “Timing setting failed-it is impossible to set the following items: initialization value”
    But I need 115200. What other settings need to be done to achieve 115200?


  3. Hello, Ben here.

    I’ve been working on a serial datalogger device. And have a question about changing the baud rate while the application is running.

    I have 2 uart devices DTE, and DCE each using the serial_ldd bean.

    I have them all initialized, receiving, and sending data fine, at the specified baud rate
    that I set in the PE settings menu for each bean.

    I noticed that there are methods for reading the rate, and changing it. PROVIDED that you have
    set up the list of possible speeds in the baud rate list. So I setup the list in the timing dialog box with 3 speeds.

    As soon as I did that, the GetSelectedBaudRate became available for use once enabled. But the SelectBaudRate method is still grayed out. Any pointers on getting the SelectBaudRate method functional?
    Once it is, I’m pretty sure I would use it like so:
    where x = (1,2,3,etc…) for each speed.



    • Hi Ben,
      I’m using the AsynchroSerial component. Then this is very easy.
      There I select for the Baud Rate ‘List of values’ with all my baud rates.
      Then this enables the SetBaudRateMode() function in the component, which can be used with the
      #define AS1_BM_9600BAUD 0 /* Baud rate constant for switch to the baud rate mode 0 */
      #define AS1_BM_38400BAUD 1 /* Baud rate constant for switch to the baud rate mode 1 */
      #define AS1_BM_12000BAUD 2 /* Baud rate constant for switch to the baud rate mode 2 */
      I have set up.


  4. Had Similar Problem with FRDM-KE04Z board, KDS 2.0.0, and KDSK 1.1.0, and processor expert for KDS 2.0.0. The desired “Hello World” would transmit properly while loading the code (perhaps from the previous run), but while running the code gibberish appeared. After I switched the baud rate of the AsynchroSerial component to 16500, and left the baud rate of Hyperterminal at 19200 I was able to get Hello World to print out properly when running the code, but gibberish when loading. Wonder what it will be like outside the debug environment? Be fun if I didn’t have other work to do!


    • I’m currently on a project using a KE06Z microcontroller, KDS 2 and Processor Expert. I had the same behavior with the serial interface, and only that combination of baud rate on the AsynchroSerial and Terminal seemed to work.

      I found the solution on this thread on freescale community.

      Apparently this is a bug in Processor Expert that configures the Internal Oscillator Clock to 32.768 kHz, which is an invalid value for this microcontroller family.
      After correcting the value to 37.5, everything started to work just fine.

      It took me some weeks to finally find this solution, I hope this helps somebody



      • Hi Daniel,
        indeed, that has been a problem, thanks for pointing to that one. I recommend that you upgrade to KDS v3.0.0 as in that version this issue has been fixed.



What do you think?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.