Hello,
I'm using Actron LizardBoard with STM32F469NIH MCU. I'm developing a rise and fall edges counter for a signal (connected to PB8 input, called DF_ENCODE1) using Timer10 Channel1 in Input Capture direct mode.
I'm having issues with the application freezing completely when I enable the timer and have a rising or falling edge of the signal.
Before integrating it with EW, I developed the application with STM32CubeIDE and tested its functionality. The application works. I then integrated the GPIO and timer10 initialization by copying the code generated by the Cube. I should point out that I've already integrated the I/O settings and the use of the SPI peripheral into the EW project, and they work.
I have the feeling that for some reason the timer10 callback isn't being executed (HAL_TIM_IC_CaptureCallback), even though it's included in the code in the file I use for device integration.
This is the inline code used for device integration:

This is the DeviceClass Init constructor:

Below is the code used to initialize timer10 in ST51PRO_tim.c file (I also reported the code that is executed by the HAL_TIM_Base_MspInit function which is called inside the HAL_TIM_Base_Init and which is normally "customized" based on the hardwar):I explicitall:
void ST51PRO_tim_TIM10_Init(void)
{
TIM_IC_InitTypeDef sConfigIC = {0};
htim10.Instance = TIM10;
htim10.Init.Prescaler = 90-1;
htim10.Init.CounterMode = TIM_COUNTERMODE_UP;
htim10.Init.Period = 65535;
htim10.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim10.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim10) != HAL_OK)
{
Error_Handler();
}
//Explicit code from HAL_TIM_Base_MspInit
__HAL_RCC_TIM10_CLK_ENABLE();
HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 10, 0);
HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn);
//End of explicit code
if (HAL_TIM_IC_Init(&htim10) != HAL_OK)
{
Error_Handler();
}
sConfigIC.ICPolarity = TIM_INPUTCHANNELPOLARITY_BOTHEDGE;
sConfigIC.ICSelection = TIM_ICSELECTION_DIRECTTI;
sConfigIC.ICPrescaler = TIM_ICPSC_DIV1;
sConfigIC.ICFilter = 0;
if (HAL_TIM_IC_ConfigChannel(&htim10, &sConfigIC, TIM_CHANNEL_1) != HAL_OK)
{
Error_Handler();
}
}
This is the code to enable timer10:
void ST51PRO_tim_Start_Encoder1Counter(void)
{
HAL_TIM_IC_Start_IT(&htim10, TIM_CHANNEL_1); //Abilito interrupt timer10 (segnale DF_ENCODER1)
}
This is the callback function on ST51PRO_DevInt.c file:
//Callback capture timer10
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
DF_DIRECTION_TOGGLE; //Debug signal
//Timer10 (encoder1)
if (htim->Instance == htim10.Instance) //Vedo segnale per capire se fronte salita o discesa
{
if (HAL_GPIO_ReadPin(DF_ENCODER1_GPIO_Port, DF_ENCODER1_Pin) == 1)
In.df_encoder1_rise++;
else
In.df_encoder1_fall++;
}
}
I added a pin toggle (DF_DIRECTION) debug signal to see if callback is called, but nothing happens.
To see that application freezes, I added a rectangle color animation effect that changes rectangle color from white to black and when there is a rise/fall edge on DF_ENCODER1 signal the animation stops.
I understand it's not easy to provide support for device integration, but the code with ST works, so I don't understand why it seems like the program crashes when the interrupt rises. I've also tried changing the interrupt's priority and excluding as many other code as possible (SPI initialization, etc...), but I still get the same result (program freeze).
If I don't start the timer (i.e., I don't run the ST51PRO_tim_STartEncoder1Counter() function), the code doesn't crash, but obviously it doesn't count any edges!
I can provide you all the code needed to better understand the issue.
Thank you for help!