mbed
Fork of mbed-dev by
Diff: targets/TARGET_Freescale/TARGET_K20XX/pwmout_api.c
- Revision:
- 151:5eaa88a5bcc7
- Parent:
- 149:156823d33999
diff -r 02e0a0aed4ec -r 5eaa88a5bcc7 targets/TARGET_Freescale/TARGET_K20XX/pwmout_api.c --- a/targets/TARGET_Freescale/TARGET_K20XX/pwmout_api.c Tue Nov 08 17:45:16 2016 +0000 +++ b/targets/TARGET_Freescale/TARGET_K20XX/pwmout_api.c Thu Nov 24 17:03:03 2016 +0000 @@ -27,8 +27,11 @@ PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM); MBED_ASSERT(pwm != (PWMName)NC); + uint32_t MGCOUTClock = SystemCoreClock * (1u + ((SIM->CLKDIV1 & SIM_CLKDIV1_OUTDIV1_MASK) >> SIM_CLKDIV1_OUTDIV1_SHIFT)); + uint32_t BusClock = MGCOUTClock / (1u + ((SIM->CLKDIV1 & SIM_CLKDIV1_OUTDIV2_MASK) >> SIM_CLKDIV1_OUTDIV2_SHIFT)); + uint32_t clkdiv = 0; - float clkval = SystemCoreClock / 1000000.0f; + float clkval = BusClock / 1000000.0f; while (clkval > 1) { clkdiv++;