File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed
libraries/mbed/targets/hal/TARGET_Freescale Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -99,11 +99,11 @@ void pwmout_write(pwmout_t* obj, float value) {
99
99
value = 1.0 ;
100
100
}
101
101
102
- * obj -> CnV = (uint32_t )((float )(* obj -> MOD ) * value );
102
+ * obj -> CnV = (uint32_t )((float )(* obj -> MOD + 1 ) * value );
103
103
}
104
104
105
105
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 );
107
107
return (v > 1.0 ) ? (1.0 ) : (v );
108
108
}
109
109
@@ -118,7 +118,7 @@ void pwmout_period_ms(pwmout_t* obj, int ms) {
118
118
// Set the PWM period, keeping the duty cycle the same.
119
119
void pwmout_period_us (pwmout_t * obj , int us ) {
120
120
float dc = pwmout_read (obj );
121
- * obj -> MOD = (uint32_t )(pwm_clock * (float )us );
121
+ * obj -> MOD = (uint32_t )(pwm_clock * (float )us ) - 1 ;
122
122
pwmout_write (obj , dc );
123
123
}
124
124
Original file line number Diff line number Diff line change @@ -78,12 +78,12 @@ void pwmout_write(pwmout_t* obj, float value) {
78
78
value = 1.0 ;
79
79
}
80
80
81
- * obj -> CnV = (uint32_t )((float )(* obj -> MOD ) * value );
81
+ * obj -> CnV = (uint32_t )((float )(* obj -> MOD + 1 ) * value );
82
82
* obj -> CNT = 0 ;
83
83
}
84
84
85
85
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 );
87
87
return (v > 1.0 ) ? (1.0 ) : (v );
88
88
}
89
89
@@ -98,7 +98,7 @@ void pwmout_period_ms(pwmout_t* obj, int ms) {
98
98
// Set the PWM period, keeping the duty cycle the same.
99
99
void pwmout_period_us (pwmout_t * obj , int us ) {
100
100
float dc = pwmout_read (obj );
101
- * obj -> MOD = (uint32_t )(pwm_clock * (float )us );
101
+ * obj -> MOD = (uint32_t )(pwm_clock * (float )us ) - 1 ;
102
102
pwmout_write (obj , dc );
103
103
}
104
104
You can’t perform that action at this time.
0 commit comments