Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-src by
Diff: targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c
- Revision:
- 264:91fcbf887208
- Parent:
- 227:7bd0639b8911
- Child:
- 363:12a245e5c745
--- a/targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c Tue Jul 22 09:15:07 2014 +0100 +++ b/targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c Wed Jul 23 08:45:10 2014 +0100 @@ -78,12 +78,12 @@ value = 1.0; } - *obj->CnV = (uint32_t)((float)(*obj->MOD) * value); + *obj->CnV = (uint32_t)((float)(*obj->MOD + 1) * value); *obj->CNT = 0; } float pwmout_read(pwmout_t* obj) { - float v = (float)(*obj->CnV) / (float)(*obj->MOD); + float v = (float)(*obj->CnV) / (float)(*obj->MOD + 1); return (v > 1.0) ? (1.0) : (v); } @@ -98,7 +98,7 @@ // Set the PWM period, keeping the duty cycle the same. void pwmout_period_us(pwmout_t* obj, int us) { float dc = pwmout_read(obj); - *obj->MOD = (uint32_t)(pwm_clock * (float)us); + *obj->MOD = (uint32_t)(pwm_clock * (float)us) - 1; pwmout_write(obj, dc); }