Work on the following tips and see if you can get to somewhere with more specific questions to answer.įor starters you should heed the comments in the HAL boilerplate code: 1) implement your own HAL_TIM_IC_CaptureCallback so CubeMX doesn't overwrite your code. There's a few things wrong with it so far, so it will be difficult to get to the right answer in one go. ![]() Is this the right way to get the period? I would appreciate any guidance as this is my first time using input capture. In the while loop I have another variable: counterVal = _HAL_TIM_GetCounter(htim2) InputCaptureVal = _HAL_TIM_GetCounter(htim) The HAL_TIM_IC_CaptureCallback could be implemented in the user file * NOTE : This function should not be modified, when the callback is needed, ![]() * Prevent unused argument(s) compilation warning */ Now, in the code I have: void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim) Everytime a pulse is given, a falling edge occurs. The TIM2 prescaler is 1000 and the counter period is 10000. In CubeMx I've set Timer 2, Channel 3 Input Capture Mode. ![]() ![]() If I get the period of the signal, then I can apply the formula: For low PPRs, using the Period Measurement Method is suggested. I'm trying to measure low speeds with a 1 PPR (pulse per revolution) sensor.
0 Comments
Leave a Reply. |