cancel
Showing results for 
Search instead for 
Did you mean: 

Timer interrupt IRQHandler error.

Joaquim Porte
Associate
Posted on April 19, 2017 at 14:28

Hello,

I'm tring to reset a LED register with a timer (TIM4) interrupt, but TIM4_IRQHandler(void); fucntion it's never launch, the code that i'm using is: (mi board es STM32f429I-DISC1).

Some one can help me please?

Thank you very much for your attention

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include 'stm32f4xx.h'

TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;

void INTTIM_Config(void)

{

NVIC_InitTypeDef NVIC_InitStructure;

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE);

TIM_TimeBaseStructure.TIM_Period = 10 - 1;

TIM_TimeBaseStructure.TIM_Prescaler =84 - 1;

TIM_TimeBaseStructure.TIM_ClockDivision = 0;

TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);

TIM_ITConfig(TIM4, TIM_FLAG_Update, ENABLE);

TIM_Cmd(TIM4, ENABLE);

NVIC_InitStructure.NVIC_IRQChannel = TIM4_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_SetPriority(TIM4_IRQn, NVIC_EncodePriority(4,15,0));

NVIC_EnableIRQ(TIM4_IRQn);

NVIC_Init(&NVIC_InitStructure);

}

int main(void) {

GPIO_InitTypeDef GPIO_InitDef;

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);

GPIO_InitDef.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14;

GPIO_InitDef.GPIO_Mode = GPIO_Mode_OUT;

GPIO_InitDef.GPIO_OType = GPIO_OType_PP;

GPIO_InitDef.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_InitDef.GPIO_Speed = GPIO_Speed_100MHz;

//Initialize pins

GPIO_Init(GPIOG, &GPIO_InitDef);

GPIO_SetBits(GPIOG, GPIO_Pin_13 | GPIO_Pin_14);

INTTIM_Config();

while (1) {

}

}

void TIM4_IRQHandler(void)

{

GPIO_ResetBits(GPIOG, GPIO_Pin_13 | GPIO_Pin_14);

if (TIM_GetITStatus(TIM4, TIM_FLAG_Update) != RESET)

{

TIM_ClearFlag(TIM4, TIM_FLAG_Update);

GPIO_ResetBits(GPIOG, GPIO_Pin_13 | GPIO_Pin_14);

}

}
1 REPLY 1
T J
Lead
Posted on April 20, 2017 at 01:23

did you start the timer ?

in uV5 you can check the peripheral registers on the fly,

you can check if the timer is running.

I start timer 15 above the while(1)

        HAL_TIM_Base_Start(&htim15);