Skip to content

Commit e2c6cf5

Browse files
committed
fix: Increases drive strength of 32kHz external crystal, in line with calculations specified in ST AN2867 sections 3.3, 3.4, and STM32L4 datasheet DS12023 Table 58. LSE oscillator characteristics.
The drive strength RCC_LSEDRIVE_LOW is marginal for the 32kHz crystal oscillator stability, and RCC_LSEDRIVE_MEDIUMLOW meets the calculated drive strength with a small margin for parasitic capacitance.
1 parent cb6201d commit e2c6cf5

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ports/stm/boards/swan_r5/mpconfigboard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
#define BOARD_HAS_LOW_SPEED_CRYSTAL (1)
4646
#define BOARD_HAS_HIGH_SPEED_CRYSTAL (0)
4747

48+
// Increase drive strength of 32kHz external crystal, in line with calculations specified in ST AN2867 sections 3.3, 3.4, and STM32L4 datasheet DS12023 Table 58. LSE oscillator characteristics.
49+
// The drive strength RCC_LSEDRIVE_LOW is marginal for the 32kHz crystal oscillator stability, and RCC_LSEDRIVE_MEDIUMLOW meets the calculated drive strength with a small margin for parasitic capacitance.
50+
#define BOARD_LSE_DRIVE_LEVEL RCC_LSEDRIVE_MEDIUMLOW
4851

4952
// Bootloader only
5053
#ifdef UF2_BOOTLOADER_ENABLED

ports/stm/peripherals/stm32l4/clocks.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
#error HSE support needs to be added for the L4 family.
4040
#elif !BOARD_HAS_LOW_SPEED_CRYSTAL
4141
#error LSE clock source required
42+
#elif !defined(BOARD_LSE_DRIVE_LEVEL)
43+
#error BOARD_LSE_DRIVE_LEVEL is not defined for this board. The board should define the drive strength of 32kHz external crystal in line with calculations specified in ST AN2867 sections 3.3, 3.4, and STM32L4 datasheet DS12023 Table 58, LSE oscillator characteristics.
4244
#endif
4345

4446
void Error_Handler(void) {
@@ -57,7 +59,7 @@ void stm32_peripherals_clocks_init(void) {
5759

5860
// Configure LSE Drive
5961
HAL_PWR_EnableBkUpAccess();
60-
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);
62+
__HAL_RCC_LSEDRIVE_CONFIG(BOARD_LSE_DRIVE_LEVEL);
6163
__HAL_RCC_PWR_CLK_ENABLE();
6264

6365
/** Configure the main internal regulator output voltage

0 commit comments

Comments
 (0)