Browse Source

cpu/stm32f3: set i2c clk input to sysclk when HSI is deactivated

According to the STM32F3 clocktree (ref. manual p. 126) the I2CX
hardware is driven by either HSI or SYSCLK.
If HSI is deactivated SYSCLK clock must be selected as I2CX clock.

Signed-off-by: Steffen Pengel <steffen.pengel@gmail.com>
master
Steffen Pengel 6 years ago
parent
commit
c7e334d3dc
  1. 10
      cpu/stm32f3/cpu.c

10
cpu/stm32f3/cpu.c

@ -140,5 +140,15 @@ static void cpu_clock_init(void)
/* disable the HSI if we use the HSE */
RCC->CR &= ~(RCC_CR_HSION);
while (RCC->CR & RCC_CR_HSIRDY) {}
/* swith I2Cx clock source to SYSCLK */
RCC->CFGR3 &= ~(RCC_CFGR3_I2CSW);
RCC->CFGR3 |= RCC_CFGR3_I2C1SW_SYSCLK;
#ifdef RCC_CFGR3_I2C2SW_SYSCLK
RCC->CFGR3 |= RCC_CFGR3_I2C2SW_SYSCLK;
#endif
#ifdef RCC_CFGR3_I2C3SW_SYSCLK
RCC->CFGR3 |= RCC_CFGR3_I2C3SW_SYSCLK;
#endif
#endif
}

Loading…
Cancel
Save