@@ -220,7 +220,6 @@ void pwmout_write(pwmout_t* obj, float value) {
220
220
#ifdef FUMC_MTU2_PWM
221
221
/* PWM by MTU2 */
222
222
st_mtu2_ctrl_t * p_mtu2_ctl = & mtu2_ctl [(int )(obj -> pwm - MTU2_PWM_OFFSET )];
223
- uint32_t wk_pulse ;
224
223
uint8_t tmp_tstr_st ;
225
224
226
225
if (value < 0.0f ) {
@@ -231,7 +230,6 @@ void pwmout_write(pwmout_t* obj, float value) {
231
230
// Do Nothing
232
231
}
233
232
wk_cycle = (uint32_t )* p_mtu2_ctl -> period1 ;
234
- wk_pulse = (uint32_t )* p_mtu2_ctl -> pulse1 ;
235
233
if ((obj -> ch == 4 ) || (obj -> ch == 3 )) {
236
234
tmp_tstr_st = (1 << (obj -> ch + 3 ));
237
235
} else {
@@ -240,23 +238,24 @@ void pwmout_write(pwmout_t* obj, float value) {
240
238
241
239
// set channel match to percentage
242
240
if (value == 1.0f ) {
243
- if (wk_pulse != wk_cycle ) {
241
+ if (* p_mtu2_ctl -> tior != 0x66 ) {
244
242
MTU2TSTR &= ~tmp_tstr_st ;
245
243
* p_mtu2_ctl -> tior = 0x66 ;
246
244
}
247
245
} else if (value == 0.0f ) {
248
- if (wk_pulse != 0 ) {
246
+ if (* p_mtu2_ctl -> tior != 0x11 ) {
249
247
MTU2TSTR &= ~tmp_tstr_st ;
250
248
* p_mtu2_ctl -> tior = 0x11 ;
251
249
}
250
+ } else if (((uint8_t )p_mtu2_ctl -> port & 0x0F ) == 0x01 ) {
251
+ if (* p_mtu2_ctl -> tior != 0x56 ) {
252
+ MTU2TSTR &= ~tmp_tstr_st ;
253
+ * p_mtu2_ctl -> tior = 0x56 ;
254
+ }
252
255
} else {
253
- if (( wk_pulse == wk_cycle ) || ( wk_pulse == 0 ) ) {
256
+ if (* p_mtu2_ctl -> tior != 0x65 ) {
254
257
MTU2TSTR &= ~tmp_tstr_st ;
255
- if (((uint8_t )p_mtu2_ctl -> port & 0x0F ) == 0x01 ) {
256
- * p_mtu2_ctl -> tior = 0x56 ;
257
- } else {
258
- * p_mtu2_ctl -> tior = 0x65 ;
259
- }
258
+ * p_mtu2_ctl -> tior = 0x65 ;
260
259
}
261
260
}
262
261
* p_mtu2_ctl -> pulse1 = (uint16_t )((float )wk_cycle * value );
0 commit comments