cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407VGT on Discovery Board. Timer2 input channel 2 PA1 is not triggering Input Capture interrupt. Timer2 Clock 84Mhz.(HSE with PLL for clock) void HAL_TIM_IC_CaptureCallback() is not invoking even after applying proper signal to Timer2 IC pin.

George_Costanza
Associate II

I have tried to create a PWM signal using Timer1 and then feed that to Timer2 running in Input Capture mode. The Timer1 PWM output is working fine and verified using DSO. But in case of Timer2 the Input Capture interrupt call back void HAL_TIM_IC_CaptureCallback() is not invoking even after applying proper signal. Also checked the hardware connection properly and made sure the PWM signal is reaching the Timer 2 Input capture pin using DSO.

Tried with a 100Hz signal from a signal generator also. While debugging the IC callback

interrupt is not invoking for some reasons. See configurations below:

0693W00000QLFBoQAP.png0693W00000QLDyuQAH.png0693W00000QLDyZQAX.png0693W00000QLDy5QAH.png0693W00000QLDwiQAH.png0693W00000QLDw4QAH.png0693W00000QLDtyQAH.png 

0693W00000QLDucQAH.png

6 REPLIES 6

Which STM32?

Which pin? What hardware? Have you measured the input signal directly on the pin of the mcu?

Read out and check/post content of TIM and relevant GPIO registers.

JW

Hi waclawek.jan,

The program code is generated using CubeMX inside CubeIDE and only added the necessary IC_Callback and init calls on main function. The code added screenshot is attached on the main post.

Using stm32f407vgt on discovery board. In my case I have followed all necessary steps by configuring Timer 2 in Input Capture mode on input channel 2 for Rising Edge and also tried in input channel 1 too. But both of the channel is not triggering input capture interrupt HAL_TIM_IC_CaptureCallback().

Also used 100Hz the input using a function generator to trigger the Timer2 Input capture at PA1. Verified whether signal is arriving at PA1 using DSO.

The program is not invoking the the IC callback function and this is checked using debugger.

Checked the internet regarding this matter and only find the same code and configuration which is currently implemented in the program. Also you can refer the screenshot of configuration made in CubeMX and for further details needed feel free to ask

Read out and check/post content of TIM and relevant GPIO registers.

JW

Already did some research on STM32 forums as well google before posting and try to find the similar issue on this forum. Most of the post they forgot to call the below function for Timers to work properly in main()..

 HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_1);

 HAL_TIM_Base_Start_IT(&htim2);

 if(HAL_TIM_IC_Start(&htim2, TIM_CHANNEL_2) != HAL_OK){

    Error_Handler();

 }

In my case I did already those kind of initilization and startup routines.. The interrupt is not triggering. If missing something can you point to specific post you meant by "TIM and relevant GPIO registers".

Regarding GPIO registers the CubeMX is generating code and when step through code using debugger proper values are updated on the registers...

> proper values are updated on the registers...

Show us those values.

Also note that debugging is intrusive and if debugger reads the TIMx_CCRx registers, it clears the corresponding interrupt flags in TIMx_SR.

JW​

Few people in other community helped me to figure out the problem. It was as below:

Instead of HAL_TIM_IC_Start() , I should use HAL_TIM_IC_Start_IT() since I'm dealing with Input Capture Interrupt. This solved the issue. The tutorial I followed used HAL_TIM_IC_Start(), but not sure how they got the right result.

Hope this would be helpful to others too.