AnsweredAssumed Answered

Can't configure Timer2 configuration registers

Question asked by Pellek on Aug 13, 2012
Latest reply on Aug 14, 2012 by Pellek
Hi.

I'm trying to use Input Capture mode on Timer2 (channel 3) on an STM8S105 (discovery board). It won't work, and when i m watching peripheral registers with appropriated breakpoints, the registers aren't changing from default value.
I m using STVD with cosmic compiler. I'm using firmware libraries. (i already checked out, that every macros was pointing to the right register.)
Here's everything relevant in my code :



    CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER2, ENABLE);

   GPIO_Init(GPIOD, GPIO_PIN_2, GPIO_MODE_IN_PU_NO_IT);
    //!\ modify option bytes : select TIMR2-CH3 for AFR1

    TM2_DISABLE;  //macro resetting CEN bit in TMR2->CR1 register

    TIM2_DeInit();

    TIM2_TimeBaseInit(TIM2_PRESCALER_1, 0xFEFE);  // changed from FFFF to FEFE to see if it applies any change to ARR register, and it does not :/
   
    TIM2_ICInit(TIM2_CHANNEL_3,
                 TIM2_ICPOLARITY_FALLING,
                 TIM2_ICSELECTION_DIRECTTI,
                 TIM2_ICPSC_DIV1,
                 0);

    TIM2_ITConfig(TIM2_IT_CC3, ENABLE);

    TIM2_CCxCmd(TIM2_CHANNEL_3, ENABLE);
    
    TM2_ENABLE;    //macro setting CEN bit in TMR2->CR1 register




Has anyone a clue on chat i forgot to enable so this peripheral might work ?

Outcomes