From 394ff7f586f3fbd8c07da50fe19cfc30ab9b0f2d Mon Sep 17 00:00:00 2001 From: Atsushi Watanabe Date: Fri, 4 Aug 2023 15:22:55 +0900 Subject: [PATCH] Explicitly set PWM invert flag --- tfrog-motordriver/controlPWM.c | 2 ++ tfrog-motordriver/main.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tfrog-motordriver/controlPWM.c b/tfrog-motordriver/controlPWM.c index 26b6f7e..22442ee 100644 --- a/tfrog-motordriver/controlPWM.c +++ b/tfrog-motordriver/controlPWM.c @@ -85,6 +85,8 @@ extern volatile char rs485_timeout; void controlPWM_config(int32_t i) { + THEVA.MOTOR[i].INVERT = 0; + switch (motor_param[i].motor_type) { case MOTOR_TYPE_DC: diff --git a/tfrog-motordriver/main.c b/tfrog-motordriver/main.c index 7ebc07e..31d2a58 100644 --- a/tfrog-motordriver/main.c +++ b/tfrog-motordriver/main.c @@ -716,10 +716,12 @@ int main() { AT91C_BASE_WDTC->WDTC_WDCR = 1 | 0xA5000000; - if (err_chk++ % 20 == 0) + if (err_chk++ % 30 == 0) { if ((volatile int32_t)THEVA.GENERAL.PWM.HALF_PERIOD != saved_param.PWM_resolution || - (volatile int32_t)THEVA.GENERAL.PWM.DEADTIME != saved_param.PWM_deadtime) + (volatile int32_t)THEVA.GENERAL.PWM.DEADTIME != saved_param.PWM_deadtime || + THEVA.MOTOR[0].INVERT != 0 || + THEVA.MOTOR[1].INVERT != 0) { err_cnt++; controlPWM_init();