Question
Stm32f4 tim7 interrupt problem
Posted on July 26, 2013 at 16:48
Hi 2All!
I'm trying to toggle LED with TIM7 interrupt. I'm using STM32f417VG with Coocox CoIDE Code is here:void
TIM7Config(
void
)
{
//RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM7,ENABLE);
/*TIM7->PSC = 63000 - 1;
TIM7->ARR = 1000 ;
TIM7->DIER |= TIM_DIER_UIE;
TIM7->CR1 |= TIM_CR1_CEN; */
//NVIC_EnableIRQ(TIM7_IRQn);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM7, ENABLE);
TIM_TimeBaseInitTypeDef TIM_TimeBase_InitStructure;
TIM_TimeBase_InitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
TIM_TimeBase_InitStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBase_InitStructure.TIM_Period = 42000;
TIM_TimeBase_InitStructure.TIM_Prescaler = 1000;
TIM_TimeBaseInit(TIM7, &TIM_TimeBase_InitStructure);
TIM_ITConfig(TIM7, TIM_IT_Update, ENABLE);
NVIC_InitStructure.NVIC_IRQChannel = TIM7_IRQn;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 4;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 3;
NVIC_Init(&NVIC_InitStructure);
TIM_Cmd(TIM7, ENABLE);
}
void
TIM7_IRQHandler(
void
)
{
if
(TIM4->CCR1==0){TIM4->CCR1=1000;}
else
{TIM4->CCR1=0;};
TIM7->SR=0;
} As you can see, I tried structures and direct registers access but nothing worksd.
By the way if I enter debug mode and add breakpoint at Irq handler, everything works fine. As soon as I disable the breakpoint, still nothing woks.
Please, help me!
#stm32f4-timer-tim7-interrupt