UART0 access disabled in the fsl_uart.c files for FRDM-KL25?

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

UART0 access disabled in the fsl_uart.c files for FRDM-KL25?

Contributor II

Hello NXP community,

So I was trying to set up UART communication on my FRDM-KL25 development board and came across two difficulties in the process (fixed the first difficulty and needing advice on the second but mentioning both).

  1. I had the MCU running at default System Clock set up at 48MHz and read from this post that found from the documentation that bus clock is System Clock/2 (he's referring to page 211 of the Reference Manual I think). So that meant that the default UART0 clock value was 24MHz (however, the actual clock value read from Debugger was 21MHz). Anyhow I had put baudrate as 115200 and called the UART_Init function. Here I was getting the error kStatus_UART_BaudrateNotSupport since I was crossing the 3% margin between desired and actual baudrate values. This was because the FW was calculating the below SBR value (see in yellow) as 11.39

    Because of having SBR value as 11 (truncating the decimals), the actual baudrate exceeded the 3% margin (see red box). Is this okay or an expected behavior?
    Me reducing the System Clock to 24MHz - hence reducing bus clock for UART0 to 12MHz - apparently resolved the issue? Thoughts?

  2. The next failure came literally after a line from an assert fail because the fsl_uart.c wasn't able to find my UART0 macro (defined in fsl_uart.h) in their list of available UARTs!

    Basically the assert failed since it couldn't find the UART0 memory address from the array of supported UART memory addresses named as s_uartBases. And here's the culprit:


    UART0 isn't a part of this list! Any thoughts on this?

    1. I know UART0 is different from UART1 and UART2 in that for UART0 you need to do some additional configurations in the MCU (enable the UART0 clock, specify what clock should be driving this peripheral, etc) that are not needed for UART1 and UART2. So is there another special function to initialize this UART0?

    2. Would it be safe to add UART0 to be a part of this array UART_BASE_PTRS?

I know I can do away with this problem by configuring UART1/2 instead and forget about it. But I'm curious to know if there's something to know here for UART0? Maybe it's something I missed in the Reference Manual?

Hope someone could help, thanks again

0 Kudos
3 Replies

NXP TechSupport
NXP TechSupport

Hi @fireflies_at_night 

I'll be reviewing your post and I'll let you know when I have an answer.

Could you please help me by clarifying some of my own questions please?

1. Are you using MCUXpresso IDE? Which version?

2. Which version of the SDK are you using? And your project is based on an example or are you using only the drivers?

3. Do you want to use the UART to send and recieve data from a serial terminal with your PC? 

I'll be waiting for the response.

Best Regards, Miguel.

0 Kudos

Contributor II

Hi @Miguel04 ,

Thanks for taking the time to look into this!

1. Yes I am using MCUXpresso IDE.version 11.4.1


2. For the SDK version I see that I'm using 2.1.4 for UART driver. Hope this is what you are asking.


Yes, I've looked up the driver examples for UART, specifically the interrupt option, and then implemented the APIs in my code.

3. And yes, my current application is to use the terminal to communicate to the board.

Also, FYI, I had set up UART2 yesterday and it works! I could send a character 'I' from the board to the terminal and the system could read any single byte character sent from the terminal


I'm using AWAVO as my terminal monitor and Semihosting Console to Debug the FW.

If it helps, I've also attached a zip that contains the test code. There's a macro in the main file MKL25Z4_Project.c called TESTUARTBASE where you can try out the working UART2 operation and toggle to UART0 that isn't able to be initialized.

0 Kudos

NXP TechSupport
NXP TechSupport

Hi @fireflies_at_night 

Sorry for the late reply.

I'm currently working on your case and I would like to review the project you share with me, however, I'm not able to see through:

UART_WriteByte(); and DB_PRINT();

I want to review the uart write byte function specially.

Regarding your questions:

The UART0 is defined aside the other uart instances on the MKL25Z4.h file.


Also, according to the schematic of the FRDM-KL25Z, using the UART2 to print on the terminal should not be possible since the UART0 instance is the one connected to the K20 OpenSDA interface on the FRDM-KL25Z, I would like to review completely the project and try out my self your configuration to verify my understanding.

I would like to recommend you to update the MCUXpresso IDE version, right now the newer version is the 11.8 and the FRDM-KL25Z's SDK currently is on the 2.2 version, we recommend to use the newer versions since they come with some bug fixes.

Best Regards, Miguel.