Skip to content

Commit

Permalink
soc: arm: stm32: fix startup SystemCoreClock values
Browse files Browse the repository at this point in the history
Current STM32 SoC initialization code sets really weird startup values
to SystemCoreClock. It should be consistent with Reference Manuals after
this change.

Signed-off-by: Ilya Tagunov <tagunil@gmail.com>
  • Loading branch information
tagunil authored and galak committed Jan 8, 2018
1 parent 4694ffe commit 935d0ce
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions arch/arm/soc/st_stm32/stm32f0/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ static int stm32f0_init(struct device *arg)
irq_unlock(key);

/* Update CMSIS SystemCoreClock variable (HCLK) */
/* At reset, System core clock is set to 4MHz */
SystemCoreClock = 4000000;
/* At reset, system core clock is set to 8 MHz from HSI */
SystemCoreClock = 8000000;

return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion arch/arm/soc/st_stm32/stm32f1/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ static int stm32f1_init(struct device *arg)

irq_unlock(key);

/* At reset, SystemCoreClock is set to HSI()8MHz */
/* Update CMSIS SystemCoreClock variable (HCLK) */
/* At reset, system core clock is set to 8 MHz from HSI */
SystemCoreClock = 8000000;

return 0;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/soc/st_stm32/stm32f3/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ static int stm32f3_init(struct device *arg)
irq_unlock(key);

/* Update CMSIS SystemCoreClock variable (HCLK) */
/* At reset, System core clock is set to 4MHz */
SystemCoreClock = 4000000;
/* At reset, system core clock is set to 8 MHz from HSI */
SystemCoreClock = 8000000;

return 0;
}
Expand Down
9 changes: 2 additions & 7 deletions arch/arm/soc/st_stm32/stm32f4/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,9 @@ static int st_stm32f4_init(struct device *arg)

irq_unlock(key);

#ifdef CONFIG_CLOCK_CONTROL_STM32_CUBE
/* Update CMSIS SystemCoreClock variable (HCLK) */
/* At reset, System core clock is set to 4MHz */
SystemCoreClock = 4000000;
#else
/* Update CMSIS SystemCoreClock variable (HCLK) */
SystemCoreClock = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
#endif /* CONFIG_CLOCK_CONTROL_STM32_CUBE */
/* At reset, system core clock is set to 16 MHz from HSI */
SystemCoreClock = 16000000;

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/soc/st_stm32/stm32l4/soc.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static int stm32l4_init(struct device *arg)
irq_unlock(key);

/* Update CMSIS SystemCoreClock variable (HCLK) */
/* At reset, System core clock is set to 4MHz */
/* At reset, system core clock is set to 4 MHz from MSI */
SystemCoreClock = 4000000;

return 0;
Expand Down

0 comments on commit 935d0ce

Please sign in to comment.