AnsweredAssumed Answered

TIM flags automatically set when TIM enabled

Question asked by kumar.rachit on Jun 19, 2013
Latest reply on Jan 19, 2014 by Clive One

I am facing a problem with the timers I am using in STM32f100 MCU.

I have configured different timers to operate during the execution of the code, but somehow, all the flags related to Capture/compare or Update in the SR are set as soonas I enable the timer.

As I read in the datasheet, they are all set in the hardware, and even if I clear them manually in debug mode, they are set again immidiately.

My configuration for TIM3, for example, does not need any CC functionality, though i do use it in other timers. But considering that I need TIM3 only for generating a time base, I still dont understand why should the CC flags in SR be set.

Below is the snapshot where I enable the TIM3 and the flags are set.


The configuration for TIM3 is as follows,

void TIM3_config(void)
    TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructTIM3;
    NVIC_InitTypeDef NVIC_Init_TIM3 = {TIM3_IRQn, 2, 1, ENABLE};

    RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
    TIM_TimeBaseStructTIM3.TIM_Period = 0x75A0;
    TIM_TimeBaseStructTIM3.TIM_Prescaler = 1;
    TIM_TimeBaseStructTIM3.TIM_ClockDivision = TIM_CKD_DIV4;
    TIM_TimeBaseStructTIM3.TIM_CounterMode = TIM_CounterMode_Up;
    TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructTIM3);
    /* TIM IT enable */

//    TIM_ClearFlag(TIM3, TIM_FLAG_Update);
    TIM_ITConfig(TIM3, TIM_IT_Update, ENABLE);

If you have any ideas where I should start looking for the problem, it'll be very helpful to progress in my work.