Skip to content
Snippets Groups Projects
Commit 1f8f7ec9 authored by Christos Gentsos's avatar Christos Gentsos
Browse files

PWM: slightly modify PWM duty cycle calculations

parent ae44969f
Branches
No related merge requests found
......@@ -27,15 +27,15 @@ uint16_t frpms_lin[3];
#define TOTAL_PWM_CLOCKS 255
uint16_t curr_pwm_duty1000_1 __xMR = 10;
uint16_t curr_pwm_duty1000_2 __xMR = 10;
uint16_t curr_pwm_duty1000_3 __xMR = 10;
int16_t curr_pwm_duty1000_1 __xMR = 10;
int16_t curr_pwm_duty1000_2 __xMR = 10;
int16_t curr_pwm_duty1000_3 __xMR = 10;
#define FAN_RAMPUP 800
uint16_t goal_pwm_duty1000_1 __xMR = FAN_RAMPUP;
uint16_t goal_pwm_duty1000_2 __xMR = FAN_RAMPUP;
uint16_t goal_pwm_duty1000_3 __xMR = FAN_RAMPUP;
int16_t goal_pwm_duty1000_1 __xMR = FAN_RAMPUP;
int16_t goal_pwm_duty1000_2 __xMR = FAN_RAMPUP;
int16_t goal_pwm_duty1000_3 __xMR = FAN_RAMPUP;
static uint16_t iter __xMR;
static uint16_t fan_ramp_up_count __xMR = 0;
......@@ -161,9 +161,13 @@ void __xMR update_pwm()
curr_pwm_duty1000_3 = 0;
}
pwm_set_parameters(&PWM_0, TOTAL_PWM_CLOCKS, TOTAL_PWM_CLOCKS*(float)(curr_pwm_duty1000_1/1000.0));
pwm_set_parameters(&PWM_1, TOTAL_PWM_CLOCKS, TOTAL_PWM_CLOCKS*(float)(curr_pwm_duty1000_2/1000.0));
pwm_set_parameters(&PWM_2, TOTAL_PWM_CLOCKS, TOTAL_PWM_CLOCKS*(float)(curr_pwm_duty1000_3/1000.0));
uint16_t target_duty_1 = (TOTAL_PWM_CLOCKS*curr_pwm_duty1000_1)/1000;
uint16_t target_duty_2 = (TOTAL_PWM_CLOCKS*curr_pwm_duty1000_2)/1000;
uint16_t target_duty_3 = (TOTAL_PWM_CLOCKS*curr_pwm_duty1000_3)/1000;
pwm_set_parameters(&PWM_0, TOTAL_PWM_CLOCKS, (target_duty_1 < 255)?(target_duty_1):(254));
pwm_set_parameters(&PWM_1, TOTAL_PWM_CLOCKS, (target_duty_2 < 255)?(target_duty_2):(254));
pwm_set_parameters(&PWM_2, TOTAL_PWM_CLOCKS, (target_duty_3 < 255)?(target_duty_3):(254));
}
void __xMR adc_cb(const struct adc_async_descriptor *const descr, const uint8_t channel)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment