Skip to content

Commit 762d47e

Browse files
committed
Fix bugs of PWM driver.
Bugs are as below. - In the case of MTU2 mode, modify a problem that does not excute "pwmout_write ()" at the end of "pwmout_pulsewidth_us ()" function. - In the case of MTU2 mode in "pwmout_period_us ()" function, modify a problem that the executing result of "set_mtu2_duty_again ()" function does not reflect in the register of TGRA_MATCH [] and TGRC_MATCH [].
1 parent 3ad80eb commit 762d47e

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

targets/TARGET_RENESAS/TARGET_RZ_A1H/pwmout_api.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,6 @@ void pwmout_period_us(pwmout_t* obj, int us) {
409409
if (pwm_mode == MODE_MTU2) {
410410
/* PWM by MTU2 */
411411
int tmp_pwm;
412-
uint16_t tmp_tgra;
413-
uint16_t tmp_tgrc;
414412
uint8_t tmp_tcr_up;
415413
uint8_t tmp_tstr_sp;
416414
uint8_t tmp_tstr_st;
@@ -467,12 +465,10 @@ void pwmout_period_us(pwmout_t* obj, int us) {
467465
*MTU2_PWM_MATCH[tmp_pwm][MTU2_PERIOD] = (uint16_t)wk_cycle; // Set period
468466

469467
// Set duty again(TGRA)
470-
tmp_tgra = *TGRA_MATCH[obj->ch];
471-
set_mtu2_duty_again(&tmp_tgra, wk_last_cycle, wk_cycle);
468+
set_mtu2_duty_again(TGRA_MATCH[obj->ch], wk_last_cycle, wk_cycle);
472469
if ((obj->ch == 0) || (obj->ch == 3) || (obj->ch == 4)) {
473470
// Set duty again(TGRC)
474-
tmp_tgrc = *TGRC_MATCH[obj->ch];
475-
set_mtu2_duty_again(&tmp_tgrc, wk_last_cycle, wk_cycle);
471+
set_mtu2_duty_again(TGRC_MATCH[obj->ch], wk_last_cycle, wk_cycle);
476472
}
477473
*TMDR_MATCH[obj->ch] = 0x02; // PWM mode 1
478474

@@ -566,7 +562,6 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
566562
value = (float)us / (float)period_ch1;
567563
}
568564
}
569-
570-
pwmout_write(obj, value);
571565
}
566+
pwmout_write(obj, value);
572567
}

targets/TARGET_RENESAS/TARGET_VK_RZ_A1H/pwmout_api.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,6 @@ void pwmout_period_us(pwmout_t* obj, int us) {
542542
if (pwm_mode == MODE_MTU2) {
543543
/* PWM by MTU2 */
544544
int tmp_pwm;
545-
uint16_t tmp_tgra;
546-
uint16_t tmp_tgrc;
547545
uint8_t tmp_tcr_up;
548546
uint8_t tmp_tstr_sp;
549547
uint8_t tmp_tstr_st;
@@ -600,12 +598,10 @@ void pwmout_period_us(pwmout_t* obj, int us) {
600598
*MTU2_PWM_MATCH[tmp_pwm][MTU2_PERIOD] = (uint16_t)wk_cycle; // Set period
601599

602600
// Set duty again(TGRA)
603-
tmp_tgra = *TGRA_MATCH[obj->ch];
604-
set_mtu2_duty_again(&tmp_tgra, wk_last_cycle, wk_cycle);
601+
set_mtu2_duty_again(TGRA_MATCH[obj->ch], wk_last_cycle, wk_cycle);
605602
if ((obj->ch == 0) || (obj->ch == 3) || (obj->ch == 4)) {
606603
// Set duty again(TGRC)
607-
tmp_tgrc = *TGRC_MATCH[obj->ch];
608-
set_mtu2_duty_again(&tmp_tgrc, wk_last_cycle, wk_cycle);
604+
set_mtu2_duty_again(TGRC_MATCH[obj->ch], wk_last_cycle, wk_cycle);
609605
}
610606
*TMDR_MATCH[obj->ch] = 0x02; // PWM mode 1
611607

@@ -699,7 +695,6 @@ void pwmout_pulsewidth_us(pwmout_t* obj, int us) {
699695
value = (float)us / (float)period_ch1;
700696
}
701697
}
702-
703-
pwmout_write(obj, value);
704698
}
699+
pwmout_write(obj, value);
705700
}

0 commit comments

Comments
 (0)