Skip to content

Commit 7df2622

Browse files
committed
SPI clock fix for KL05Z and KL46Z
1 parent ed7954f commit 7df2622

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL05Z/spi_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ void spi_frequency(spi_t *obj, int hz) {
115115
uint8_t ref_prescaler = 0;
116116

117117
// bus clk
118-
uint32_t PCLK = 23986176u;
118+
uint32_t PCLK = SystemCoreClock / (((SIM->CLKDIV1 & SIM_CLKDIV1_OUTDIV4_MASK) >> SIM_CLKDIV1_OUTDIV4_SHIFT) + 1);
119119
uint8_t prescaler = 1;
120120
uint8_t divisor = 2;
121121

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KL46Z/spi_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ void spi_frequency(spi_t *obj, int hz) {
158158
uint8_t ref_prescaler = 0;
159159

160160
// bus clk
161-
uint32_t PCLK = 48000000u;
161+
uint32_t PCLK = SystemCoreClock / (((SIM->CLKDIV1 & SIM_CLKDIV1_OUTDIV4_MASK) >> SIM_CLKDIV1_OUTDIV4_SHIFT) + 1);
162162
uint8_t prescaler = 1;
163163
uint8_t divisor = 2;
164164

0 commit comments

Comments
 (0)