cancel
Showing results for 
Search instead for 
Did you mean: 

Using a timer interrupt on the F7 discovery

riktw
Associate
Posted on October 16, 2015 at 15:34

Hello,

A bit of a beginner question here.

I want to have a timer interrupt to trigger every x mS.

This is the code I've made so far but it's not triggering any interrupt.

int uwPrescalerValue = (uint32_t) ((SystemCoreClock /2) / 10000) - 1;

    htim3.Instance = TIM3;

    htim3.Init.Prescaler = uwPrescalerValue;

    htim3.Init.CounterMode = TIM_COUNTERMODE_UP;

    htim3.Init.Period = 100;

    htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;

    if(HAL_TIM_Base_Init(&htim3) != HAL_OK)

      {

        while(1)

        {

        }

      }

    if(HAL_TIM_Base_Start_IT(&htim3) != HAL_OK)

      {

        while(1)

        {

        }

      }

    __HAL_RCC_TIM3_CLK_ENABLE();

      /* Set the TIMx priority */

      HAL_NVIC_SetPriority(TIM3_IRQn, 0, 1);

      /* Enable the TIMx global Interrupt */

      HAL_NVIC_EnableIRQ(TIM3_IRQn);

Am I missing something to enable the timer interrupt here?

Best regards,

Rik

0 REPLIES 0