CubeMX clock code generation bug (stm32f103c8t6)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-03-22 2:46 PM
Hi,
I'd like to report a potential bug in the code generation / clock initialisation code for the STM32F103c8t6.
Cube version 4.2
STM32CubeF1 Release 1.4.0
Keil uVision 5.22
I have attached the very simple project and cube file. The line that fails is 339 in stm32f1xx_hal_rcc.c
I am not using HSI as a system clock.
Any help most appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-03-23 2:33 AM
Hello Glen,
this is a bug I found it yesterday too. Go to your main.c file and removeRCC_OSCILLATORTYPE_HSI on line 133.
This happens if you have setup HSI clock first, export project and later setup HSE clock as source.
Why it fails?
Because configuration for HSIState and HSICalibrationValue are missing now (removed from CubeMX generation tool) and have unknown value and assert_param goes to assert_failed function. When you removeRCC_OSCILLATORTYPE_HSI from first line, configuration won't try to init HSI clock.
How to reproduce the bug:
- Create new empty project (In my case I used STM32F746) in CubeMX
- In RCC IP add HSIexternal crystal mode
- Go to clock control and select HSIas PLL source and configure PLL
- Export project, open in IDE, compile and run.
- Project will work with HSI (High Speed Internal) clock.
- Go back to CubeMX and in the same project configure HSE value as PLL source
- Export and look at main.c where clock configuration is setup.
- You will still seeRCC_OSCILLATORTYPE_HSI for OscillatorType.
- It means that we still want to init HSI clock
- But there is no HSIState and HSICalibrationValue parameters in initialization structure
- FunctionHAL_RCC_OscConfig will try to init HSE and HSI and it will fail at HSI setup because of missing HSI important parameters.
First code export
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON; //HSI State is here
RCC_OscInitStruct.HSICalibrationValue = 0; //HSI calibration value is here
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 16;
RCC_OscInitStruct.PLL.PLLN = 432;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}�?�?�?�?�?�?�?�?�?�?�?�?�?
Second code export
//HSI is still here for oscillator type, but there are missing important HSI parameters
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE;
//missing here
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 25;
RCC_OscInitStruct.PLL.PLLN = 432;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = 2;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
//First line should be
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-03-23 3:44 AM
Hello,
Please note that this is a confirmed CubeMX bug which will be fixed in a patch to be delivered soon.
Sorry for such inconvenience.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-03-23 5:11 AM
Fantastic, thanks for the comprehensive reply.
Cheers
Glen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-03-23 5:48 AM
Hi Amel,
Is the list of known issues with CubeMX available to view?
Cheers
Glen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-03-23 6:23 AM
Hi Glen,
Unfortunately, no list currently available.
I raise this request -again- internally.
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-03-23 6:32 AM
I second the motion. RELEASE NOTES is sorely needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-04-20 2:51 AM
Hello
glenc
‌,If you aren't already aware, this regression bug is fixed and a patch is delivered end of March (CubeMX v4.1).
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
