mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
Diff: targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c
- Revision:
- 264:91fcbf887208
- Parent:
- 227:7bd0639b8911
--- 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); }