cancel
Showing results for 
Search instead for 
Did you mean: 

timer 4 interrupt not generated in STM8S103 series!?

hg_chen
Associate II
Posted on November 19, 2009 at 10:13

timer 4 interrupt not generated in STM8S103 series!?

6 REPLIES 6
hg_chen
Associate II
Posted on May 17, 2011 at 15:04

As we know that timer 4 is the common timer for STM8S10X and 20X series,

A code with timer 4 interrupt can work fine in STM8S20X series,but fails to generate timer 4 interrupt when trying in STM8S103F3 or K3 IC,

Has anyone encounter the same problem that timer 4 interrupt failed in STM8S103 series?

or what may be need to notice in the setting?

mozra27
Associate II
Posted on May 17, 2011 at 15:04

Hi,

The Update/Overflow interrupts works fine for TIM4 on STM8S103K3

In the stm8s.h file you can select the target according to the STM8S device used in your application.

Thanks to check this point and let me know if have again the issue

Regards

mozra

keskintaylan
Associate II
Posted on May 17, 2011 at 15:04

Dear Sir,

I have a same problem with all timers(UPD/OV) on STM8S103F2!

In debuging the counters aren't counting. You said Edit STM8S.h . Editing what?

Please give me an example if i use TIM2 Update/Overflow interrupt.

Thank You.

[ This message was edited by: keskintaylan on 19-11-2009 11:58 ]

mozra27
Associate II
Posted on May 17, 2011 at 15:04

Hi,

This function configure the timer2 to generate an update each 5ms using the STM8S FWLib, it can help you:

void Init_TIM2(void)

{

/* TimerTick = 5 ms

Warning: fcpu must be equal to 16MHz

fck_cnt = fck_psc/presc = fcpu/512 = 31.25 kHz --> 1 tick every 32 µs

==> 5 ms / 32 µs = 156 ticks

*/

TIM2_TimeBaseInit( TIM2_PRESCALER_512, 156);

TIM2_UpdateRequestConfig(TIM2_UPDATESOURCE_GLOBAL);

TIM2_ITConfig(TIM2_IT_UPDATE, ENABLE);

/* Enable interrupts */

enableInterrupts();

TIM2_Cmd(ENABLE);

}

Regards

mozra

ne562
Associate II
Posted on May 17, 2011 at 15:04

>> Has anyone encounter the same problem that timer 4 interrupt failed in STM8S103 series?

The same problem with STM8S103F3P6 (on STM8S105 in Discovery code works fine):

setup:

TIM4_CR1 = 1;

TIM4_PSCR = 7;

TIM4_IER = 1;

rim();

interrupt:

TIM4_SR &= ~1;

in debugger TIM4_IER == 0
ne562
Associate II
Posted on May 17, 2011 at 15:04

The problem was in inclusion of wrong header file (iostm8s.h instead of iostm8s103.h), now works ok