Skip to content

Commit d67af43

Browse files
committed
Fix condition statement of write function
1 parent c5b01bf commit d67af43

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

targets/TARGET_RENESAS/TARGET_RZ_A1XX/pwmout_api.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ void pwmout_write(pwmout_t* obj, float value) {
220220
#ifdef FUMC_MTU2_PWM
221221
/* PWM by MTU2 */
222222
st_mtu2_ctrl_t * p_mtu2_ctl = &mtu2_ctl[(int)(obj->pwm - MTU2_PWM_OFFSET)];
223-
uint32_t wk_pulse;
224223
uint8_t tmp_tstr_st;
225224

226225
if (value < 0.0f) {
@@ -231,7 +230,6 @@ void pwmout_write(pwmout_t* obj, float value) {
231230
// Do Nothing
232231
}
233232
wk_cycle = (uint32_t)*p_mtu2_ctl->period1;
234-
wk_pulse = (uint32_t)*p_mtu2_ctl->pulse1;
235233
if ((obj->ch == 4) || (obj->ch == 3)) {
236234
tmp_tstr_st = (1 << (obj->ch + 3));
237235
} else {
@@ -240,23 +238,24 @@ void pwmout_write(pwmout_t* obj, float value) {
240238

241239
// set channel match to percentage
242240
if (value == 1.0f) {
243-
if (wk_pulse != wk_cycle) {
241+
if (*p_mtu2_ctl->tior != 0x66) {
244242
MTU2TSTR &= ~tmp_tstr_st;
245243
*p_mtu2_ctl->tior = 0x66;
246244
}
247245
} else if (value == 0.0f) {
248-
if (wk_pulse != 0) {
246+
if (*p_mtu2_ctl->tior != 0x11) {
249247
MTU2TSTR &= ~tmp_tstr_st;
250248
*p_mtu2_ctl->tior = 0x11;
251249
}
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+
}
252255
} else {
253-
if ((wk_pulse == wk_cycle) || (wk_pulse == 0)) {
256+
if (*p_mtu2_ctl->tior != 0x65) {
254257
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;
260259
}
261260
}
262261
*p_mtu2_ctl->pulse1 = (uint16_t)((float)wk_cycle * value);

0 commit comments

Comments
 (0)