Skip to content

Fix issue #5119, changed pwmout_api. #7716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 15, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,25 @@ void pwmout_period_us(pwmout_t* obj, int us)
FTM_Type *base = ftm_addrs[obj->pwm_name >> TPM_SHIFT];
float dc = pwmout_read(obj);

// Stop FTM clock to ensure instant update of MOD register
base->MOD = FTM_MOD_MOD((pwm_clock_mhz * (float)us) - 1);
uint32_t pwm_base_clock;
uint32_t clkdiv = 0;
pwm_base_clock = CLOCK_GetFreq(kCLOCK_BusClk);
pwm_clock_mhz = (float)pwm_base_clock / 1000000.0f;
uint32_t mod = (pwm_clock_mhz*(float)us) - 1;
while(mod > 0xFFFF){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is target code but should be same as the rest of the code here, see https://os.mbed.com/docs/latest/reference/style.html

spaces around operators and while (), etc. Please fix

++clkdiv;
pwm_clock_mhz /= 2.0f;
mod = (pwm_clock_mhz*(float)us) - 1;
if(clkdiv==7){
break;
}
}
uint32_t SC = base->SC & ~FTM_SC_PS_MASK;
SC |= FTM_SC_PS((ftm_clock_prescale_t)clkdiv);
base->SC = SC;

//Stop FTM clock to ensure instant update of MOD register
base->MOD = FTM_MOD_MOD(mod);
pwmout_write(obj, dc);
}

Expand Down