2022-10-30 10:06 PM
Set timer 6 to 3 seconds. Set timer 7 to 1.5 seconds.
Timer 7 restarts Timer 6, so I don't think it changes the variable o in Timer 6, but the variable o changes. Is there a problem?
I have confirmed that timer 6 is stopped by HAL_TIM_Base_Stop_IT(&htim6);.
I have confirmed that timer 6 is stopped. Thank you in advance.
int main(void){
__HAL_TIM_CLEAR_FLAG(&htim6, TIM_FLAG_UPDATE); //3000
__HAL_TIM_CLEAR_FLAG(&htim7, TIM_FLAG_UPDATE); //1500
HAL_TIM_Base_Start_IT(&htim6);
HAL_TIM_Base_Start_IT(&htim7);
while(1){}
}
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
if (htim == &htim6) {
o++;
}
if (htim == &htim7) {
p++;
HAL_TIM_Base_Stop_IT(&htim6);
__HAL_TIM_CLEAR_FLAG(&htim6,TIM_FLAG_UPDATE);
HAL_TIM_Base_Start_IT(&htim6) ;
}