partially solved issue with random modulator and ADC clock stopping at the end of ЛЧМ. Done: when we want to stop clocks -- enable IRQ on sloewr clock (TIM11). In IRQ switches TIM4, TIM11 to one-pulse mode, disables IRQ. When we starting these timers th next time -- we resets their counters, one-pulse mode disables.

This commit is contained in:
2025-04-15 21:29:24 +03:00
parent 0829fd0983
commit 9974606734
5 changed files with 45 additions and 2 deletions

View File

@ -421,8 +421,19 @@ int main(void)
uint16_t trigger_counter = 0;
uint16_t trigger_step = (uint8_t )((task.max_param - task.current_param)/task.delta_param * 10);
uint16_t task_sheduler = 0;
HAL_TIM_PWM_Stop(&htim11, TIM_CHANNEL_1); //start modulating by Mach-Zander modulator
HAL_TIM_PWM_Stop(&htim4, TIM_CHANNEL_3); //start modulating by Mach-Zander modulator
TIM11 -> CR1 &= ~(1 << 3); //disables one-pulse mode
TIM4 -> CR1 &= ~(1 << 3); //disables one-pulse mode
TIM11 -> CNT = 0;
TIM4 -> CNT = 0;
HAL_TIM_PWM_Start(&htim11, TIM_CHANNEL_1); //start modulating by Mach-Zander modulator
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_3); //start modulating by Mach-Zander modulator
while (task.current_param < task.max_param)
@ -468,8 +479,15 @@ int main(void)
//*/
}
}
HAL_TIM_PWM_Stop(&htim11, TIM_CHANNEL_1); //start modulating by Mach-Zander modulator
HAL_TIM_PWM_Stop(&htim4, TIM_CHANNEL_3); //start modulating by Mach-Zander modulator
TIM11 -> DIER |= 1; //enable update interrupt. In this IRQ handler we will set both tims to one-pulse mode.
//TIM11 -> CR1 |= 1 << 3; //sets timer to one-pulse mode. So it will turn off at the next UpdateEvent
//TIM4 -> CR1 |= 1 << 3; //sets timer to one-pulse mode. So it will turn off at the next UpdateEvent
//but one-pulse mode should be disabled
//HAL_TIM_PWM_Stop(&htim11, TIM_CHANNEL_1); //start modulating by Mach-Zander modulator
//HAL_TIM_PWM_Stop(&htim4, TIM_CHANNEL_3); //start modulating by Mach-Zander modulator
Stop_TIM10();