Skip to content

Commit e479081

Browse files
committed
Merge branch 'master' of https://github.com/mbedmicro/mbed
2 parents d35532b + 6663575 commit e479081

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_K20D50M/pwmout_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ void pwmout_write(pwmout_t* obj, float value) {
9999
value = 1.0;
100100
}
101101

102-
*obj->CnV = (uint32_t)((float)(*obj->MOD) * value);
102+
*obj->CnV = (uint32_t)((float)(*obj->MOD + 1) * value);
103103
}
104104

105105
float pwmout_read(pwmout_t* obj) {
106-
float v = (float)(*obj->CnV) / (float)(*obj->MOD);
106+
float v = (float)(*obj->CnV) / (float)(*obj->MOD + 1);
107107
return (v > 1.0) ? (1.0) : (v);
108108
}
109109

@@ -118,7 +118,7 @@ void pwmout_period_ms(pwmout_t* obj, int ms) {
118118
// Set the PWM period, keeping the duty cycle the same.
119119
void pwmout_period_us(pwmout_t* obj, int us) {
120120
float dc = pwmout_read(obj);
121-
*obj->MOD = (uint32_t)(pwm_clock * (float)us);
121+
*obj->MOD = (uint32_t)(pwm_clock * (float)us) - 1;
122122
pwmout_write(obj, dc);
123123
}
124124

libraries/mbed/targets/hal/TARGET_Freescale/TARGET_KLXX/pwmout_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ void pwmout_write(pwmout_t* obj, float value) {
7878
value = 1.0;
7979
}
8080

81-
*obj->CnV = (uint32_t)((float)(*obj->MOD) * value);
81+
*obj->CnV = (uint32_t)((float)(*obj->MOD + 1) * value);
8282
*obj->CNT = 0;
8383
}
8484

8585
float pwmout_read(pwmout_t* obj) {
86-
float v = (float)(*obj->CnV) / (float)(*obj->MOD);
86+
float v = (float)(*obj->CnV) / (float)(*obj->MOD + 1);
8787
return (v > 1.0) ? (1.0) : (v);
8888
}
8989

@@ -98,7 +98,7 @@ void pwmout_period_ms(pwmout_t* obj, int ms) {
9898
// Set the PWM period, keeping the duty cycle the same.
9999
void pwmout_period_us(pwmout_t* obj, int us) {
100100
float dc = pwmout_read(obj);
101-
*obj->MOD = (uint32_t)(pwm_clock * (float)us);
101+
*obj->MOD = (uint32_t)(pwm_clock * (float)us) - 1;
102102
pwmout_write(obj, dc);
103103
}
104104

0 commit comments

Comments
 (0)