Skip to content

Commit 532a643

Browse files
committed
stm32f4/f7 Fix PLL configuration
SystemInit disabled few bits in CR register before every clock was configured. This allows to configure PLL. If PLLI2S was enabled before this function was called (could happen if I2S was enabled in bootloader) PLL source could not be changed. ST HAL function HAL_RCC_OscConfig() expect this bit to be cleared. Following code from HAL will not update PLLSRC bit if PLLI2S in enabled during call to this function. /* Configure the main PLL clock source, multiplication and division factors. */ WRITE_REG(RCC->PLLCFGR, (RCC_OscInitStruct->PLL.PLLSource | \ RCC_OscInitStruct->PLL.PLLM | \ (RCC_OscInitStruct->PLL.PLLN << RCC_PLLCFGR_PLLN_Pos) | \ (((RCC_OscInitStruct->PLL.PLLP >> 1U) - 1U) << RCC_PLLCFGR_PLLP_Pos) | \ (RCC_OscInitStruct->PLL.PLLQ << RCC_PLLCFGR_PLLQ_Pos))); This clears PLLI2S bit in RCC_CR register to enable further configuration of PLL from external oscillator (same bit is already cleared in L4 devices in code provided by ST).
1 parent 48929b2 commit 532a643

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

hw/mcu/stm/stm32f4xx/src/system_stm32f4xx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ SystemInit(void)
124124
/* Reset CFGR register */
125125
RCC->CFGR = 0x00000000;
126126

127-
/* Reset HSEON, CSSON and PLLON bits */
128-
RCC->CR &= (uint32_t)0xFEF6FFFF;
127+
/* Reset HSEON, CSSON PLLI2S and PLLON bits */
128+
RCC->CR &= (uint32_t)0xFAF6FFFF;
129129

130130
/* Reset PLLCFGR register */
131131
RCC->PLLCFGR = 0x24003010;

hw/mcu/stm/stm32f7xx/src/system_stm32f7xx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ void SystemInit(void)
104104
/* Reset CFGR register */
105105
RCC->CFGR = 0x00000000;
106106

107-
/* Reset HSEON, CSSON and PLLON bits */
108-
RCC->CR &= (uint32_t)0xFEF6FFFF;
107+
/* Reset HSEON, CSSON PLLI2S and PLLON bits */
108+
RCC->CR &= (uint32_t)0xFAF6FFFF;
109109

110110
/* Reset PLLCFGR register */
111111
RCC->PLLCFGR = 0x24003010;

0 commit comments

Comments
 (0)