cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX adds incorrect value to XTAL

Rajeev Arora
Senior

Hello,

I have been observing this issue with previous as well as latest STM32CubeMX versions, wherein the generated MDK-ARM (minimum version 5.27) project file (UVPROJX) has incorrect value set to Options for Target -> Target -> Xtal (MHz).

In the IOC file I have informed that used XTAL value is 25 MHz.

In Clock configuration, I have set SYSCLK to 480 MHz and D1CPRE Prescaler to Divide by 1. thus FCLK is 480 MHz.

STM32CubeMX copying SYSCLK value to Xtal (MHz) is a BUG.

Please fix the bug.

Regards,

@rxa1031

9 REPLIES 9
Khouloud ZEMMELI
ST Employee

Hello @Rajeev Arora​ 

Could you please share your ioc file ?

Thanks

Khouloud

Hello

@Khouloud ZEMMELI​ ,

Please find attached the & ZIP file which contains both the IOC and generated project (but set to compile using Keil Compiler version 6).

Regards,

Rajeev

Rajeev Arora
Senior

Hello @Khouloud ZEMMELI​ 

There was an erratum in the information I shared. Please read "STM32CubeMX copying SYSCLK value to Xtal (MHz) is a BUG."

as

"STM32CubeMX copying 240 MHz value to Xtal (MHz) is a BUG."

The value of HPRE Prescaler is set to "/2".

Regards,

Rajeev

Khouloud ZEMMELI
ST Employee

Could you please share more details ? what do you mean by "XTAL"

Cannot find value Xtal (MHz) under project file (UVPROJX) .

Thanks

Hello @Khouloud ZEMMELI​ ,

I am not sure whether you have access to ARM / Keil's MDK-ARM compiler.

Once the IOC file is opened with the STM32CubeMX tool and code generated, a folder named MDK-ARM is created which has a file named USART-Test.uvprojx.

I open this file with help of Keil's IDE. Then in project pane I right click the text USART3-TEST which is next to folder symbol and then click on options for Target 'USART3-Test' (shortcut Alt+F7).

Under Target Tab there is this Xtal (MHz) Text box, which shows the value as 240.0 and not 25.0

I assume the reason for this issue is that the helper file / settings file USART3-Test.uvoptx is being appended with an incorrect tag value:

<CLKADS>240000000</CLKADS>

which should rather be:

<CLKADS>25000000</CLKADS>

Regards,

Rajeev

Rajeev Arora
Senior

Keil IDE informs:

Xtal (MHz)

Specifies the XTAL frequency of your device. XTAL is used to configure the debugger and Flash programmer. Note that XTAL reflects the main oscillator externally connected to the device.

Khouloud ZEMMELI
ST Employee

Hello @Rajeev Arora​ 

It's not an issue, the Xtal value takes always the HCLK frequency ( not the Sysclk freq) to ensure the proper synchronisation and functioning of the project, you can change this value if you want (as the case of MicroLIB , you change it at the end of your config project ).

Best Regards,

Khouloud

Hello @Khouloud ZEMMELI​ ,

As per information shared by Keil and the snapshot I've shared, I am of a different opinion, and my opinion matches with what ARM / Keil has informed.

I am of the opinion that STM32CubeMX must update the INPUT FREQUENCY VALUE passed to HSE (set in Clock configuration menu) as value for TAG CLKADS which is present with UVOPTX file (which the STM32CubeMX generated when informed compiler is MDK-ARM (minimum version 5)).

Xtal (MHz)

Specifies the XTAL frequency of your device. XTAL is used to configure the debugger and Flash programmer. Note that XTAL reflects the main oscillator externally connected to the device.

Please refer to attachment.

Regards,

Rajeev

@Rajeev Arora​  I'll make a double check so, then I'll back to you.

Regards,

Khouloud