AnsweredAssumed Answered

Timer Interrupt STM32F4

Question asked by kane.alexander.003 on Jun 13, 2013
Latest reply on Jun 13, 2013 by Clive One
I'm having difficulty getting a simple timer reload interupt system to work.

Once the initTimer() method is called the MCU appears to stop.  Even when I comment out "soloInd->flash();"

Any help at all would be much appreciated.

#include "stm32f4xx_tim.h"

Indicators *soloInd;
void Indicators::initTimer()
    // Use Timer 5
    TIMx = TIM5;

    NVIC_InitTypeDef NVIC_InitStructure;
    TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;

    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM5, ENABLE);

    // Initialise TimeBaseStructure with default values.
    TIM_TimeBaseInit(TIMx, &TIM_TimeBaseStructure);

    /* Enable timer 5 capture compare Interrupt */
    register_interrupt(TIM5_IRQn, Indicators::IND_IRQ_Handler);
    NVIC_InitStructure.NVIC_IRQChannel = TIM5_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

    TIM_ITConfig(TIMx, TIM_IT_Update, ENABLE);


void Indicators::IND_IRQ_Handler()
    TIM5->SR &= ~TIM_SR_UIF;

// Not sure how this method works, was already written.
inline void register_interrupt(uint8_t vector_offset,  void (*function)())
    ((uint32_t*)SCB->VTOR)[(uint16_t)vector_offset + 16] = (uint32_t)function;