TIM2 program using STM8S003F3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-02-18 6:48 PM
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 timerInterrupt 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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-02-22 4:58 AM
Have you enabled the interrupts?
Show me your interrupt table!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-02-22 4:36 PM
Thanks qwer.asdf for reply.
I got the solution of TIM2 programing. It was not related to interrupt, the values were not moving properly to each register. Since address for TIM2 registers are product dependent.
In STM8s003f3 after CR1 register the two bytes are reserved so other TIM2 registers' address has offset of 2 bytes. After making changes to program now it is finely working.
