AnsweredAssumed Answered

TIM2 program using STM8S003F3

Question asked by Thorabale.Ajit on Feb 19, 2017
Latest reply on Feb 23, 2017 by Thorabale.Ajit

Hi

I am facing problem in Timer2 programing. It does not go into the interrupt. Please find below program of Timer2 initialization. I am using STVD for programing STM8S003F3.

 

The Prescalar clock frequency is 16Mhz

 

    //Configuring TIM2 for 1 ms delay generation
    TIM2->PSCR =0x04;        //Deviding incoming clock by 16 Fck_cnt = Fck_psc/(2^PSC[3:0]);    
    TIM2->ARRH =0x03;       //ARR value with 1000
    TIM2->ARRL =0xE8;       

    TIM2->CR1 |= 0x80;      //Auto reload preload enabled

    TIM2->IER |=0x01;          //TIM2 Update Interrupt enabled
     TIM2->CR1 |= 0x01;      //ON timer

 

Interrupt routine as below in which PD6 is toggled on each interrrupt.

 

INTERRUPT_HANDLER(TIM2_UPD_OVF_BRK_IRQHandler, 13)
{
     GPIOD->ODR ^=0x40;
    TIM2->SR1 &= 0xfe; //*/

}

 

I am not getting what is wrong. Thanks in advance.

Outcomes