pwm variable now contains actual timer value

This also causes the actual PWM value to be output over UART.
This commit is contained in:
Thomas Kolb 2016-10-03 16:03:15 +02:00
parent 9b4857df1d
commit c11cb28558

View file

@ -723,14 +723,14 @@ int main(void)
pwm = fxp_to_int(controlAction); pwm = fxp_to_int(controlAction);
if(pwm >= CONV_PWM_MAX) { if(pwm > CONV_PWM_MAX) {
timer_set_oc_value(TIM1, TIM_CH_CONV, CONV_PWM_MAX); pwm = CONV_PWM_MAX;
} else if(pwm > 0) { } else if(pwm < 0) {
timer_set_oc_value(TIM1, TIM_CH_CONV, pwm); pwm = 0;
} else {
timer_set_oc_value(TIM1, TIM_CH_CONV, 0);
} }
timer_set_oc_value(TIM1, TIM_CH_CONV, pwm);
#ifdef DEBUG #ifdef DEBUG
if((time_in_state % 100) == 0) { if((time_in_state % 100) == 0) {
debug_send_string("pErr: "); debug_send_string("pErr: ");
@ -746,7 +746,7 @@ int main(void)
} }
#endif #endif
if(time_in_state > 5000 && pwm > CONV_PWM_MAX && power_state.current_avg < CURRENT_THRESHOLD) { if(time_in_state > 5000 && fxp_to_int(controlAction) > CONV_PWM_MAX && power_state.current_avg < CURRENT_THRESHOLD) {
operState = Bootstrap; operState = Bootstrap;
nextState = ConvConstVoltage; nextState = ConvConstVoltage;
} }
@ -787,14 +787,14 @@ int main(void)
pwm = fxp_to_int(controlAction); pwm = fxp_to_int(controlAction);
if(pwm >= CONV_PWM_MAX) { if(pwm > CONV_PWM_MAX) {
timer_set_oc_value(TIM1, TIM_CH_CONV, CONV_PWM_MAX); pwm = CONV_PWM_MAX;
} else if(pwm > 0) { } else if(pwm < 0) {
timer_set_oc_value(TIM1, TIM_CH_CONV, pwm); pwm = 0;
} else {
timer_set_oc_value(TIM1, TIM_CH_CONV, 0);
} }
timer_set_oc_value(TIM1, TIM_CH_CONV, pwm);
if(time_in_state > 5000 && pwm > CONV_PWM_MAX && power_state.current_avg < CURRENT_THRESHOLD) { if(time_in_state > 5000 && pwm > CONV_PWM_MAX && power_state.current_avg < CURRENT_THRESHOLD) {
operState = Bootstrap; operState = Bootstrap;
nextState = ConvConstCurrent; nextState = ConvConstCurrent;