2017-06-03 11:12 AM
I have a board which was designed to use the STM32L433CCU6 and am attempting to use it with an STM32L452CEU6. The board works perfectly fine with the 433, but I am struggling a bit with the 452. The problem I was facing is that I am attempting (and failing) to use the HSI as the clock source for LPUART1. The UART was transmitting but not being understood, and reporting errors when attempting to read.
After a bit of work, I have it working fine with the PCLK1 (via HSE/PLL) at 38400bps, but I need to operate at 9600bps. This cannot be done with an 80MHz clock.
In order to see what was going on, I connected HSI to MCO and measured the frequency. At an ambient temperature of 21C, the HSI on one MCU is running at 13.89MHz and another at 14.29MHz. That seems excessively out of spec to me. Doing some digging, it appears that the HSI is not being calibrated properly.
I am using STMCubeMX 4.20.1 and the 1.7.0 version of the L4 library to initialize the RCC.
This is the code that is generated for the calibration for both the 433 and 452:
RCC_OscInitStruct.HSICalibrationValue = 16;
This is the code that works:
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
It seems that the proper calibration values are different for the two and the Cube doesn't know that.
#stm32cubemx #hsi #lpuart #stm32l452Solved! Go to Solution.
2017-06-06 07:44 AM
Hi
Riggs.Rob
,I confirm that this issue is related to
STM32CubeMX and should be fixed to correct default configuration tothe HSI.
Also the RM should be updated for new derivatives with the number of bits containing HSITRIM[6:0] for the
RCC_HSICALIBRATION_DEFAULT default value set to 0xThanks
Imen
2017-06-04 06:13 AM
And what is the value of that RCC_HSICALIBRATION_DEFAULT ?
My reading of both RM0393 and RM0394 is that the default RCC_ICSCR.HSITRIM is 16. In fact, there's no reason to touch RCC_ICSCR at all if you want to use the factory calibration so I don't quite understand why would you want to do that.
JW
2017-06-04 12:32 PM
Hi
Waclawek.Jan
Fromstm32l4xx_hal_rcc.h:
#if defined(STM32L431xx) || defined(STM32L432xx) || defined(STM32L433xx) || defined(STM32L442xx) || defined(STM32L443xx) || \ defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx)#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x10U) /* Default HSI calibration trimming value */
#else#define RCC_HSICALIBRATION_DEFAULT ((uint32_t)0x40U) /* Default HSI calibration trimming value */
#endif /* STM32L431xx || STM32L432xx || STM32L433xx || STM32L442xx || STM32L443xx || */ /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx */The HALappears to be correct. The 'Cube pre-populates the value '16' in the GUI, that that's what it writes into the code that is generated. It should ask 'do you want to change the default?' If that's not selected, it should set it to HSI_CALIBRATION_DEFAULT. If it is selected, it should allow one to input the value.
2017-06-05 12:57 AM
ST: please fix RM0393 and RM0394 in this regard.
Also, please indicate, which of the two is mandatory for the 'L451/452.
Thanks.
JW
2017-06-05 10:03 AM
Hi
Riggs.Rob
andWaclawek.Jan
,I will raise your feedback internally to updatethe reference manual in coming release.
About the two reference manuals available on the ST web, I would inform you that the RM0394
is now updated
to support new products STM32L43xxx – STM32L44xxx – STM32L45xxx – STM32L46xxx.So, you can use the last reference manual RM0394 (
latest release
published in April 2017), then the old reference RM0393 will become obsolete and will disappearfrom the website.Regards
Imen
2017-06-05 10:20 AM
Imen,
Thanks.
I understand that the two RMs is an interim state. But, my point is, that while manuals are on the website, there should be some indicator which one is the authoritative one.
Jan
2017-06-05 06:27 PM
DAHMEN.IMEN
Please do not let this discussionabout reference manuals distract from my defect report about the STM32CubeMX behavior. The current behavior is clearly wrong. It is applying an incorrect default configuration tothe HSI on the STM32L4 Please fix that.
I have the correct reference manual for the part.
Rob
2017-06-06 02:58 AM
I have the correct reference manual for the part.
Which one? Both
RM0393
andRM0394 fail to mention the different number of bits for the 'L45x in description RCC_ICSCR.HSITRIM, or am I overlooking something?
defect report about the STM32CubeMX behavior
IMO It's both CubeMX (in generating code with constant instead of symbol) and Cube (in writing calibration register when not needed).
JW
2017-06-06 07:44 AM
Hi
Riggs.Rob
,I confirm that this issue is related to
STM32CubeMX and should be fixed to correct default configuration tothe HSI.
Also the RM should be updated for new derivatives with the number of bits containing HSITRIM[6:0] for the
RCC_HSICALIBRATION_DEFAULT default value set to 0xThanks
Imen
2017-10-15 09:33 PM
Just to let you know the issue is the same for the STM32L4ZG-P profile in the CubeMX configuration. It took me a few days and a question into stack exchange to fix it. In one way it's good to force an understanding of the clock system.
Hayden