AnsweredAssumed Answered

STM32VLDiscovery - Input capture mode

Question asked by hittive.hittive on Nov 25, 2014
Latest reply on Nov 25, 2014 by waclawek.jan
i want to capture time signal on PA0. I use a FreeRtos. My code:
//Input capture mode
    TIM1->CR1 = 0x0;
    TIM2->CCER =0x0;
    TIM2->CR1 |=TIM_CR1_CMS ;
    TIM2->CR1 |=TIM_CR1_DIR;
    TIM2->CCMR1 |=TIM_CCMR1_CC1S_0 ;//  CC1 channel is configured as input, IC1 is mapped on TI1
    TIM2->CCMR1  |=TIM_CCMR1_IC1F_0 |TIM_CCMR1_IC1F_1 ;//f    SAMPLING N=8
    //TIM2->CCER |=TIM_CCER_CC1P ;//OC1 active high
    //TIM2->CCMR1&=~TIM_CCMR1_IC1PSC  ;//Prescaler
    TIM2->CCER|=TIM_CCER_CC1E; // Capture enabled
    //TIM2->CR1|=TIM_CR1_ARPE  ; autoreload
    TIM2->CR1|=TIM_CR1_CEN; // TIM2 enable
    TIM2->DIER|=TIM_DIER_CC1IE;// interrupt enable
    TIM2->PSC  = 23999;

void TIM2_IRQHandler(void)
    if(TIM2->SR &  TIM_SR_CC1IF)
        TIM2->SR = ~TIM_SR_CC1IF;
    TIM2->CNT = 0;            //Zeruję licznik.



My signal on PA0 is PWM : 200ms high and 500ms low.
 ECHO=TIM2->CCR1 is alway 700. Why?