today I carefully studied the PWM time sequence and digged little deep about the the function
“ControlLoop_IRQHandler”. I mad a diagram about the interrupt sequence for better understanding and communication. A few information maybe wrong in this diagram, I would improve it after disscusion.
I just put motor M1 here for better presentation, and here is my understanding. point it if I am wrong :
tim 1_8 frequency is 168Mhz, according the timer set up： Prescale=0; Periode =TIM_1_8_PERIOD ( 3500), we can get the frequecy count up/down to 3500 = 168Mhz/3500 = 48Khz. That also how the black triangle wave been drawn in the diagram.
The " RepitionCounter = TIM_1_8_RCR (2) ", which means the interrupts happens 16Khz (the black square in the diagram) .
the callback functions ( current_meas_cb(); dc_calib_cb(); PWM_update_cb(); ） all updated in every timer interrupt (after timestamp3) ?
For update 0, if "current_meas_cb() " happened in timestamp 0, then the corresponding "dc_calib_cb() " happened 1 timestamp later, then “PWM_update_cb()” 3 timestamp later?
motors.dc_calib_cb(timestamp + TIM_1_8_PERIOD_CLOCKS * (TIM_1_8_RCR + 1), current1);
motors.pwm_update_cb(timestamp + 3 * TIM_1_8_PERIOD_CLOCKS * (TIM_1_8_RCR + 1));
and I red the post Oska posted many years ago, feels some data don’t fit. @madcowswe