cancel
Showing results for 
Search instead for 
Did you mean: 

Using Timer 6 - A shared interrupt

Posted on September 17, 2014 at 01:17

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 #timers
3 REPLIES 3
Posted on September 17, 2014 at 02:55

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on September 17, 2014 at 04:32

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
Posted on September 17, 2014 at 13:32

Are you using C++ (.cpp)? What tool chain, and how are you determining it's not being called?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..