2021-09-10 03:56 AM
Hello there,
I've been messing around with a development board I've recently bought, STEVAL-SPIN3204, and I've been attempting to produce a RPM measurement using one hall effect sensor input attached to the PA5 pin, which with can be set to TIM2_Channel1. Using STM32CubeIDE.
I've been following many examples that I've found online on how to set up Timer Input Capture interrupt and time and time again it didn't seem to be working out for me.
I'm still new to STM32 programming but following examples I learn quite a lot, although I'm stuck on this one problem I cannot seem to go over.
Here's some attachments that I feel should go along with this question.
Code Snip of input capture callback:
/* USER CODE BEGIN 4 */
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
if (htim->Channel == HAL_TIM_ACTIVE_CHANNEL_1) // if interrput source is channel 1
{
if (Is_First_Captured==0) // is the first value captured ?
{
IC_Value1 = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1); // capture the first value
Is_First_Captured =1; // set the first value captured as true
}
else if (Is_First_Captured) // if the first is captured
{
IC_Value2 = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1); // capture second value
if (IC_Value2 > IC_Value1)
{
Difference = IC_Value2-IC_Value1; // calculate the difference
}
}
}
}
/* USER CODE END 4 */
Also the timer setup code snip:
/* USER CODE BEGIN 2 */
HAL_TIM_IC_Start_IT(&htim2, TIM_CHANNEL_1);
/* USER CODE END 2 */
And snips from the STM32CubeIDE:
I've tried this with toggling LEDs upon an interrupt, just to test the interrupt function, no luck in that either. I'm using "Expressions" to monitor the value of the 'Diffrence' variable that should be the difference between two timer events. But that's not even working or is stuck at a constant 0.
Any assistance would be appreciated, thank you. :)
2021-09-10 04:27 AM
Read out and check/post TIM and relevant GPIO registers' content.
Some generic "interrupts don't work" hints here.
JW