cancel
Showing results for 
Search instead for 
Did you mean: 

Timer1 Interrupt is not generated

STuser2
Senior III

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.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Super User

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.

stm32f4xx-hal-driver/Src/stm32f4xx_hal_tim.c at 3a6ec1330ec2ff9cdc414f643e3d09cdf50c415e · STMicroelectronics/stm32f4xx-hal-driver

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

5 REPLIES 5
Andrew Neil
Super User

Do you have HAL_NVIC_SetPriority() and HAL_NVIC_EnableIRQ() for the timer interrupt?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

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 */

  }

}

 

waclawek.jan
Super User

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

TDK
Super User

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.

stm32f4xx-hal-driver/Src/stm32f4xx_hal_tim.c at 3a6ec1330ec2ff9cdc414f643e3d09cdf50c415e · STMicroelectronics/stm32f4xx-hal-driver

If you feel a post has answered your question, please click "Accept as Solution".

Yes it did the trick, but the videos i have gone through online it was never mentioned. Thank you for the solution.