timer1 polling:
HAL_TIM_Base_Start(&htim1);uint16_t t1=__HAL_TIM_GET_COUNTER(&htim1);
HAL_Delay(100);
uint16_t t2=__HAL_TIM_GET_COUNTER(&htim1);
uint16_t diff=t2-t1;
timer1 isr:
HAL_TIM_Base_Start_IT(&htim1); => enable 方式不同
寫在main內的 timer callback functionvoid
HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
// Check which version of the timer triggered this callback and toggle LED
if (htim == &htim1 )
{
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
}
}
不錯的文章:{
// Check which version of the timer triggered this callback and toggle LED
if (htim == &htim1 )
{
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_13);
}
}
Getting Started with STM32 - Timers and Timer Interrupts
https://www.digikey.com/en/maker/projects/getting-started-with-stm32-timers-and-timer-interrupts/d08e6493cefa486fb1e79c43c0b08cc6
沒有留言:
張貼留言