Skip to main content
Rob.Riggs
Senior
June 3, 2017
Solved

STM32L452CEU6 HSI Problem

  • June 3, 2017
  • 1 reply
  • 3461 views
Posted on June 03, 2017 at 20:12

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 #stm32l452
This topic has been closed for replies.
Best answer by Imen.D
Posted on June 06, 2017 at 14:44

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 0x

Thanks

Imen

1 reply

waclawek.jan
Super User
June 4, 2017
Posted on June 04, 2017 at 15:13

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

Rob.Riggs
Rob.RiggsAuthor
Senior
June 4, 2017
Posted on June 04, 2017 at 19:32

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.

waclawek.jan
Super User
June 5, 2017
Posted on June 05, 2017 at 07:57

ST: please fix RM0393 and RM0394 in this regard.

Also, please indicate, which of the two is mandatory for the 'L451/452.

Thanks.

JW