2026-03-10 6:37 AM - edited 2026-03-10 6:46 AM
I am using Nucleo-F446RE board and trying to verify the TIM1 update interrupt and PWM, the PWM is generated but if i put a break point in the update interrupt it does not halt, what is the reason?
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_TIM1_Init();
/* USER CODE BEGIN 2 */
HAL_TIM_PWM_Start_IT(&htim1,TIM_CHANNEL_1);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}i have put a break point in the below function
/**
* @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
*/
void TIM1_UP_TIM10_IRQHandler(void)
{
/* USER CODE BEGIN TIM1_UP_TIM10_IRQn 0 */
/* USER CODE END TIM1_UP_TIM10_IRQn 0 */
HAL_TIM_IRQHandler(&htim1);
/* USER CODE BEGIN TIM1_UP_TIM10_IRQn 1 */
/* USER CODE END TIM1_UP_TIM10_IRQn 1 */
}I am adding my cubemx project.
Solved! Go to Solution.
2026-03-10 7:45 AM
As @waclawek.jan suggests, the update interrupt is enabled with HAL_TIM_Base_Start_IT. Use that before the call to HAL_TIM_PWM_Start_IT.
2026-03-10 7:17 AM
Do you have HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ() for the timer interrupt?
2026-03-10 7:24 AM - edited 2026-03-10 7:24 AM
Thank you for reply, how do i check it? If i verify the hal_msp.c file as below it is available.
void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm)
{
if(htim_pwm->Instance==TIM1)
{
/* USER CODE BEGIN TIM1_MspInit 0 */
/* USER CODE END TIM1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM1_CLK_ENABLE();
/* TIM1 interrupt Init */
HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn);
/* USER CODE BEGIN TIM1_MspInit 1 */
/* USER CODE END TIM1_MspInit 1 */
}
}
2026-03-10 7:38 AM - edited 2026-03-10 7:39 AM
I don't use Cube/HAL, but HAL_TIM_PWM_Start_IT() sounds that it woulduse the CC-interrupt, rather than Update-interrupt, if any. For TIM1, those are separate vectors, TIM1_CC for the CC interrupts and TIM1_UP_TIM10 for the Update.
If not this, a generic interrupt does not fire checklist here.
JW
2026-03-10 7:45 AM
As @waclawek.jan suggests, the update interrupt is enabled with HAL_TIM_Base_Start_IT. Use that before the call to HAL_TIM_PWM_Start_IT.
2026-03-10 8:07 AM
Yes it did the trick, but the videos i have gone through online it was never mentioned. Thank you for the solution.