AnsweredAssumed Answered

STM32F4 - read timer value

Question asked by pano.samuele on Nov 24, 2014
Latest reply on Nov 25, 2014 by Clive One
Hi,
I have this timer
void InitializeTimer(void)
{     
        TIM_TimeBaseInitTypeDef timerInitStructure;
        NVIC_InitTypeDef NVIC_InitStructure;
        RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
     
    timerInitStructure.TIM_Prescaler = 0;
    timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
    timerInitStructure.TIM_Period = (84000000 / 2000) - 1; //2000Hz                              
    timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
    timerInitStructure.TIM_RepetitionCounter = 0;
     
     
        /* Activación de la interrupción  */
        NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;     //Activa todos los canales
        NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
        NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
        NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
         
        TIM_TimeBaseInit(TIM2, &timerInitStructure); // guarda cambios en init timer
        NVIC_Init(&NVIC_InitStructure);             // guarda cambios en el registro nvic
             
        //Activa el Timer  
        TIM_Cmd(TIM2, ENABLE);                                         
        TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
}
how to read the value from the main fuction?

thanks

Outcomes