[MCUXpresso][Tool] Issue with Clock Tools in MCUXpresso

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

[MCUXpresso][Tool] Issue with Clock Tools in MCUXpresso

1,215 Views
JF_Gagnon
Contributor II

Hello,

We started using MCUXpresso ConfigTools and we have this strange issue. We are using the MIMXRT1060-EVK devboard, with MCUXpresso 5.11.0.

When configuring the clocks through the Clock tool in ConfigTools, the settings aren't taken into account.

For example, when using the MIMXRT1060-EVK board in an empty project and the LPUART driver, the clock configuration is 4MHz in the Clock Tool.

JF_Gagnon_0-1652973146441.png

 

I configure the LPUART to 115200 bauds. If I want to have the baudrate of 115200, when I init the port with the function status_t LPUART_Init(LPUART_Type *base, const lpuart_config_t *config, uint32_t srcClock_Hz), if I use the configured speed of 4MHz as above, I get a baudrate that is 20 times faster.

When looking through the MIMXRT1060-EVK example of the LPUART, I can see that the UART_CLK_ROOT is set to 80MHz which is 20 times faster than 4MHz.

So even with the clock diagram configure with 4MHz, I need to initialize the LPUART with a clockspeed of 80MHz to get the right baud rate of 115200.

So my question is this : Why are the clock configs not taken into account with the generated code? And how can I make sure that the clocks configured are used?

Thanks,
Jean-Francois

Labels (1)
Tags (2)
0 Kudos
5 Replies

1,199 Views
JF_Gagnon
Contributor II

To recreate the issue:

1) Create a new empty project from the MIMXRT1060-EVK SDK. Choose an empty board profile.

JF_Gagnon_0-1653053245210.png


2) In the config tool for the Pins, make sure that the LPUART3 TX and RX pins are configured to J12 and K10 pins. This is the pin 2 and 1 from the Arduino connector J22.

JF_Gagnon_1-1653053341990.png

3) In the Clock tool, leave the configuration as it is. The UART_CLK_ROOT by default is 4MHz.

JF_Gagnon_2-1653053428620.png

4) In the Peripherals config tool, enable LPUART3 and set as polling. The Clock Source Frequency is set as 4MHz and Baudrate set to 115200.

JF_Gagnon_3-1653053625543.png


5) Update the code to generate the appropriate files. The ConfigTools generates a function called BOARD_InitBootPeripherals(). In that fonction, the LPUART3 is initialized with the value of LPUART3_CLOCK_SOURCE which is equal to 4000000UL (4MHz).

JF_Gagnon_9-1653055357483.png

JF_Gagnon_10-1653055376797.png

 

 


6) I add a simple LPUART_WriteBlocking() call In the main loop of 1 char.

JF_Gagnon_5-1653054185295.png

 

With a speed of 115200 bauds, it should take around 69us to transmit 8 bits. However, when looking at the logic analyzer data, we see that it takes 3.5us to transmit 8 bits with the current configuration. 69/3.5 = 19.7 which is around 20 times faster.

JF_Gagnon_6-1653054899165.png

 


When looking at the examples of the sdk, the dev kit is configured to run at high speeds (600Mhz) and the Uart Clock is configured as 80Mhz which is 20 times faster than 4Mhz.

In the current code, if I init the port with 80Mhz instead of the 4MHz that is configured in the Clock tools, I get the right timing.

JF_Gagnon_7-1653054960758.pngJF_Gagnon_8-1653055017267.png


That means that the clock tool isn't configuring the mcu properly and we still have the clock speed of 600MHz even though the clock tool is configured as 24MHz.

We've had the same issue with the CAN FD bus. How can that be fixed. How can the clock settings be properly applied?

0 Kudos

1,187 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thanks for your reply.
According to the above steps, I also created a new project, however, UART_CLK_ROOT is 80 MHz default, and my MCUXpresso IDE is v11.5.0.

jeremyzhou_0-1653272519711.pngjeremyzhou_1-1653272528330.png

Further, I'd like to suggest you choose the Default board files when creating a new project.

Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,172 Views
JF_Gagnon
Contributor II

If the project is created with Default Board, the clock is configured at 600MHz. If the project is created with empty Board, the clock is configured at 24MHz.

However, that doesn't change the fact that whatever configuration is used, the generated code should be accurate to what the ConfigTools is showing and that is causing us issue.

If the UART_CLK_ROOT is 4MHz, I should be able to use 4000000UL to have an accurate baudrate.

0 Kudos

1,045 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Sorry for replying late.
After checking, the UART_CLK_ROOT should be 80 MHz instead of 4Mh, when booting from the QSPI, the PFD_480_PFD1 is selected as the FLEXSPI clock, which means it will not reconfigure the USB1_PLL in the BOARD_BootClockRUN() function, in another word, the corresponding code of the below clock path will be ignored.

jeremyzhou_0-1658115101017.pngjeremyzhou_1-1658115148010.png


You can check the value of CCM's register to confirm, as UART_CLK_ROOT is 80 MHz, however you use the 4 MHz to configure the baud rate, so the real baud rate becomes 20 times faster finally.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

 

0 Kudos

1,202 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
1) Why are the clock configs not taken into account with the generated code? And how can I make sure that the clocks configured are used?
-- To be prudent, I was wondering if you can demonstrate the steps of replicating the phenomenon.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos