Enable Timer interrupt after generating N pulse
Are you using CubeMX?
If yes then you have to first enable it in NVIC after configuring TIM4.
Next, inside your logic you have to enable the timer as HAL_TIM_IC_Start_IT(&amp;htim4, TIM_CHANNEL_1);