pwm variable now contains actual timer value
This also causes the actual PWM value to be output over UART.
This commit is contained in:
parent
9b4857df1d
commit
c11cb28558
26
src/main.c
26
src/main.c
|
@ -723,14 +723,14 @@ int main(void)
|
|||
|
||||
pwm = fxp_to_int(controlAction);
|
||||
|
||||
if(pwm >= CONV_PWM_MAX) {
|
||||
timer_set_oc_value(TIM1, TIM_CH_CONV, CONV_PWM_MAX);
|
||||
} else if(pwm > 0) {
|
||||
timer_set_oc_value(TIM1, TIM_CH_CONV, pwm);
|
||||
} else {
|
||||
timer_set_oc_value(TIM1, TIM_CH_CONV, 0);
|
||||
if(pwm > CONV_PWM_MAX) {
|
||||
pwm = CONV_PWM_MAX;
|
||||
} else if(pwm < 0) {
|
||||
pwm = 0;
|
||||
}
|
||||
|
||||
timer_set_oc_value(TIM1, TIM_CH_CONV, pwm);
|
||||
|
||||
#ifdef DEBUG
|
||||
if((time_in_state % 100) == 0) {
|
||||
debug_send_string("pErr: ");
|
||||
|
@ -746,7 +746,7 @@ int main(void)
|
|||
}
|
||||
#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;
|
||||
nextState = ConvConstVoltage;
|
||||
}
|
||||
|
@ -787,14 +787,14 @@ int main(void)
|
|||
|
||||
pwm = fxp_to_int(controlAction);
|
||||
|
||||
if(pwm >= CONV_PWM_MAX) {
|
||||
timer_set_oc_value(TIM1, TIM_CH_CONV, CONV_PWM_MAX);
|
||||
} else if(pwm > 0) {
|
||||
timer_set_oc_value(TIM1, TIM_CH_CONV, pwm);
|
||||
} else {
|
||||
timer_set_oc_value(TIM1, TIM_CH_CONV, 0);
|
||||
if(pwm > CONV_PWM_MAX) {
|
||||
pwm = CONV_PWM_MAX;
|
||||
} else if(pwm < 0) {
|
||||
pwm = 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) {
|
||||
operState = Bootstrap;
|
||||
nextState = ConvConstCurrent;
|
||||
|
|
Loading…
Reference in a new issue