AnsweredAssumed Answered

Timer 2 isr not firing unless in debug mode

Question asked by blesener.daniel on Aug 14, 2013
Latest reply on Aug 14, 2013 by blesener.daniel
Strange problem...Timer 2 works great when debugging. When I turn my supply off and reboot, everything is hunky dory except timer2. Any clues?

    TIM_DeInit(TIM2);

    //ENABLE CLOCKS
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);

    //TIM2 INIT
    TIM_TimeBaseInitTypeDef TIM2_struct;
    TIM2_struct.TIM_ClockDivision = 0;
    TIM2_struct.TIM_CounterMode = TIM_CounterMode_Up;
    TIM2_struct.TIM_Period = 4000;                      //Timer2 is clcoked at 48MHz with prescaler of 0; SOLVE(1/48000000 * X = 1/8000, X) gives interrupt time of 100uS when being used. Perfect for our SPI
    TIM2_struct.TIM_RepetitionCounter = 0;              //This is only valid for timer 1 and 8

    TIM_TimeBaseInit(TIM2, &TIM2_struct);

    TIM_OCInitTypeDef  TIM_OCInitStructure;
    TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Timing;
    TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
    TIM_OCInitStructure.TIM_Pulse = 0;
    TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_Low;

    TIM_OC1Init(TIM2, &TIM_OCInitStructure);

    TIM_OC1PreloadConfig(TIM2, TIM_OCPreload_Disable);

    TIM_ARRPreloadConfig(TIM2, ENABLE);

    /* TIM2 enable counter */
    TIM_Cmd(TIM2, ENABLE);
   
        //INTERRUPT CONFIG
    NVIC_InitTypeDef TIM2_isr_struct;
    TIM2_isr_struct.NVIC_IRQChannel = TIM2_IRQn;
    TIM2_isr_struct.NVIC_IRQChannelCmd = ENABLE;
    TIM2_isr_struct.NVIC_IRQChannelPreemptionPriority = 0;
    TIM2_isr_struct.NVIC_IRQChannelSubPriority = 1;

    NVIC_Init(&TIM2_isr_struct);
   
        /* TIM IT enable */
    TIM_ITConfig(TIM2, TIM_IT_CC1  , ENABLE);



Outcomes