2015-07-10 01:34 PM
I'm trying to configure Timer2, and I've initialized it as follows based on some sample code, but I'm not sure how I'm supposed to handle the IRQ it generates.
Usually I would use TIM2_IRQHandler for example, but some samples I see use HAL_TIM_IRQHandler. Can someone explain what this new function is for?I'm also unable to check the status of the interrupt the way I used to using the TIM_GetITStatus function or clear the interrupt using TIM_ClearITPendingBitvoid WS2812_Timer_Init(void){ TIM_HandleTypeDef TimHandle; uint16_t PrescalerValue = (uint16_t) (SystemCoreClock / 24000000) - 1;; __TIM2_CLK_ENABLE(); TimHandle.Instance = WS2812_Timer; TimHandle.Init.Period = Timer_Period; TimHandle.Init.Prescaler = PrescalerValue; TimHandle.Init.ClockDivision = 0; TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP; /* Initialize Timer */ HAL_TIM_Base_Init(&TimHandle); /* Start Timer Interrupts */ HAL_TIM_Base_Start_IT(&TimHandle); /*##-2- Configure the NVIC for TIMx ########################################*/ /* Set Interrupt Group Priority */ HAL_NVIC_SetPriority(WS2812_Timer_IRQ, 0, 1); /* Enable the TIMx global Interrupt */ HAL_NVIC_EnableIRQ(WS2812_Timer_IRQ);}2015-07-14 07:21 AM
Hi bujak.dan,
It seems that you have some confusion between the Standard Peripheral Library (SPL) functions and the STM32Cube (HAL) ones.In fact, TIM_GetITStatus and the others are available in the SPL. The code you provided is based on HAL drivers.Have a look to STM32Cube_FW_F4_V1.6.0\Projects\STM32F4-Discovery\Examples\TIM\TIM_TimeBase for example. The function handling TIM interrupt request is HAL_TIM_IRQHandler. You may replace TIM3 by TIM2 of course.-Mayla-To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.