I am a beginner, I am using the stm32F103 interrupt function TIM1_IRQHandler function to count, but HAL_TIM_PerodElapsedCallback can also achieve accurate counting, which one should I choose to use? What is the difference between these two functions?
Asked
Active
Viewed 1,242 times
1
-
1If you're using the STM HAL library, then it should already contain a TIM1_IRQHandler function to handle the interrupt at the end of the timer period. That library IRQ handler will in turn call your implementation of HAL_TIM_PeriodElapsedCallback. If you're going to use the library functions to configure/start/stop the timer, then it probably makes sense to also use the library's IRQ handler and write your Callback function. If you're instead writing to the timer registers to config/start/stop instead of using the HAL library, then it would make sense to write your own IRQ handler too. – brhans Apr 30 '20 at 11:25
-
Thanks for your answers. – eehongzhijun May 01 '20 at 00:57
-
This question is asked and answered on StackOverflow. [What is the difference between IRQ Handler and Callback function?](https://stackoverflow.com/questions/60545912/what-is-the-difference-between-irq-handler-and-callback-function) For that question on StackOverflow, the title asks the general question: "What is the difference between IRQ Handler and Callback function?" However, on StackOverflow, the question's text and answers address the more specific question asked here: "What is the difference between TIMx_IRQHandler and HAL_TIM_PeriodElapsedCallback function?" – JimYuill Sep 02 '22 at 15:35