STM32L031K6 Custom Board - External 32.768 kHz Crystal Issue
Post edited by ST moderator to be inline with the community rules for the code sharing. In next time please use </> button to paste your code. Please read this post: How to insert source code.
Hello everyone,
I have designed a custom PCB using the STM32L031K6 microcontroller. The board includes an external 32.768 kHz crystal oscillator (LSE - Low Speed External).
The Problem:
I am flashing code to the board using an ST-Link. When running a simple LED blinking application (which uses HAL_Delay), the LED either blinks only once or gets stuck indefinitely within the HAL_Delay function. This strongly suggests an issue with the microcontroller's clock configuration or the LSE activation.
Hardware and Code Details:
-
MCU: STM32L031K6
-
External Oscillator: 32.768 kHz (LSE)
-
Development Environment: STM32CubeIDE
-
Library Used: STM32Cube HAL
-
Problematic Function: HAL_Delay() (This function relies on a properly running clock source, usually SysTick).
I will attach the following:
-
Schematic:

-
Clock Configuration:
-
Simple Example Code:
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_12);
HAL_Delay(250);
}
/* USER CODE END 3 */
}Any help or suggestions from someone who has faced this issue, especially regarding the LSE configuration or clock startup sequence on the L0 series, would be highly appreciated! Thank you!
