RCC_LSEConfig Example Description

Enabling/disabling of the low-speed external(LSE) RC oscillator (about 32 KHz) at run time, using the RCC HAL API.

In this example, after startup SYSCLK is configured to the max frequency using HSI48 as clock source, the User push-button (connected to EXTI_Line13) is used to enable/disable LSE:

Each time the User push-button is pressed, EXTI_Line13 interrupt is generated and the ISR enables the LSE when it is off, disables it when it is on.

LED4 is toggling as follows according to LSE activation:

LSE clock waveform is available on the MCO1 pin PA.08 and can be captured on an oscilloscope.

In case of configuration error, LED4 is slowly blinking (1 sec. Period).

Notes

  1. Care must be taken when using HAL_Delay(), this function provides accurate delay (in milliseconds) based on variable incremented in SysTick ISR. This implies that if HAL_Delay() is called from a peripheral ISR process, then the SysTick interrupt must have higher priority (numerically lower) than the peripheral interrupt. Otherwise the caller ISR process will be blocked. To change the SysTick interrupt priority you have to use HAL_NVIC_SetPriority() function.

  2. The application need to ensure that the SysTick time base is always set to 1 millisecond to have correct HAL operation.

Keywords

System, RCC, PLL, PLLCLK, SYSCLK, LSE, Clock, Oscillator,

Directory contents

Hardware and Software environment

How to use it ?

In order to make the program work, you must do the following :