mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #3233 from brimston3/fix_k20_pwmclk
K20xx Calculate PWM clock relative to bus clockpull/3241/head
commit
31c81131df
|
@ -27,8 +27,11 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
|
|||
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++;
|
||||
|
|
Loading…
Reference in New Issue