cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L452 LSE not starting

SLevi.1
Associate III

I have an STM32L452 rigged to use an external clock so we can keep the RTC running. Schematic attached.LSE_schem.png

X2 is a clock from SiTime, programmed to be 32.768kHz. C36 is a supercap acting as battery backup. I used STMCube to generate the startup code to feed into HAL_RCC_OscConfig. When I debug into this function, the LSE never becomes ready (RCC_BDCR_LSERDY bit always zero), and so the code returns HAL_TIMEOUT.

Do I have the correct circuit? Have I set the clock config correctly? It's the same if I run on a Nucleo board.

/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSE;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 2;
RCC_OscInitStruct.PLL.PLLN = 36;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV7;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV4;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV4;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}

18 REPLIES 18

Tried setting RCC pwr on, before setting PWR->CR4: Still no joy.

 

SET_BIT(RCC->APB1ENR1, RCC_APB1ENR1_PWREN);

PWR->CR4 |= PWR_CR4_VBRS_Msk; // use 1.5kOhms, gives 3.02v out
PWR->CR4 |= PWR_CR4_VBE_Msk; // enable output

i would do a simple test now: connect a 3v batt, cr2032 typ. , to vbat . (no super-cap)

without any problems from charging etc. you should get rtc working (as everybody -- like me is doing.)

then - if you see this working, try with only the cap again.

If you feel a post has answered your question, please click "Accept as Solution".

Wouldn't put a LED on PC15, it low current, and on the battery/low-power domain

RM suggests some sequencing is involved LSEON needs to be zero to enable LSEBYP.

You should be able to a) get the LSE out of a pin, b) measure the frequency with a TIM internally.

 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I looked at the clock going into the RCC_OSC_In pin (3), and saw a 32.768 pulse. There only looked to be around 1v peak height. What sort of amplitude should it be? LSE.bmp

I mean your config is wrong. For external active clock you in wizard ioc need config BYPASS and in config sysclock then is generated 

RCC_OscInitStruct.LSEState = RCC_LSE_BYPASS.

Turns out that the wrong clock chip had been fitted - they'd used the low-power variant, so the swing on the clock signal was not sufficient for the processor to detect.

AAlis.23
Associate III

Schematic is wrong???. How is it going to work if you don’t have power on Vbat? You’ve placed a capacitor, and that’s it. You’re missing a diode to 3V3; otherwise, how is the capacitor going to charge?

Maybe that series has the diode integrated into the chip or a different system to provide power from the CPU to the external circuit?

No diode, but switch internal. Read my forward up...