2014-09-16 04:17 PM
Hi all
I need to use Timer 6 on the STM32F407VG. Its interrupt is sharedby one of the DAC overrun interrupts. Is there something extra I have to do compared to another timer with its own global interrupt in order to use Timer6?Thanks in advance. #stm32f4 #discovery #timers2014-09-16 05:55 PM
You'd just use TIM6_DAC_IRQn and TIM6_DAC_IRQHandler() and qualify the interrupt source as you would with any other timer, ie CC1, CC2, Update, etc.
2014-09-16 07:32 PM
I thought that was how it was done. My code is as follows:
void init_CPITimer(void)
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
NVIC_InitTypeDef NVIC_InitStructure;
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM6, ENABLE);
TIM_TimeBaseStructure.TIM_Prescaler = 42000;
TIM_TimeBaseStructure.TIM_Period = 20 - 1;
TIM_TimeBaseStructure.TIM_ClockDivision = 1;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM6, &TIM_TimeBaseStructure);
NVIC_InitStructure.NVIC_IRQChannel = TIM6_DAC_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 9;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
//USART_SendTextNL(USART1, ''TIMER SET UP'');
TIM_ITConfig(TIM6, TIM_IT_Update, ENABLE);
TIM_ClearITPendingBit(TIM6, TIM_IT_Update);
TIM_Cmd(TIM6, ENABLE);
}
void TIM6_DAC_IRQHandler(void)
{
if (TIM_GetITStatus(TIM6, TIM_IT_Update) != RESET)
{
TIM_ClearITPendingBit(TIM6, TIM_IT_Update);
PWMCountLED++;
if( PWMCountLED > 1)
{
GPIO_SetBits(GPIOB, GPIO_Pin_13);
}
if (PWMCountLED == 100)
{
PWMCountLED = 0;
CPI_Count++;
GPIO_ResetBits(GPIOB, GPIO_Pin_13);
}
}
}
The interrupt handler never fires. Is there something wrong here?
Thanks
2014-09-17 04:32 AM
Are you using C++ (.cpp)? What tool chain, and how are you determining it's not being called?