2020-07-06 08:46 AM
I have an application where I need to count the total number of pulses coming in from a fuel flow sensor. I then take the total number of pulses to display a readout of the total amount of fuel that has flowed through the sensor since the counter began. What would be the best way to do this? Timer? Regular EXTI?
Thanks!
Solved! Go to Solution.
2020-07-06 04:46 PM
Looks fine to me. Make sure your period is set to max, if that's what you want.
Proper way to read the timer counter is to read the TIMx->CNT register. TIM2->CNT in this instance. You can read this directly or use the __HAL_TIM_GET_COUNTER macro.
2020-07-06 09:36 AM
how about a tmer which clock input is the sensor's? no interrupts required.
2020-07-06 10:25 AM
Check out timer external clock modes in the reference manual. Use a 32 bit timer or handle overflows carefully if there going to be more than 65535 pulses.
2020-07-06 11:41 AM
Thanks for the help. I am trying to use the 32 bit timer 2 for my application. In the ioc application, this is the settings that I am using. Does this look alright? Also, what is the proper way to read the counter of the timer when I am in the main function?
2020-07-06 04:46 PM
Looks fine to me. Make sure your period is set to max, if that's what you want.
Proper way to read the timer counter is to read the TIMx->CNT register. TIM2->CNT in this instance. You can read this directly or use the __HAL_TIM_GET_COUNTER macro.
2020-07-07 09:07 AM
I got the timer working the way that I wanted. Thanks for the help!!!