2009-11-23 09:49 PM
STM8S103F2 TIMER EXAMPLE(needed please)
2011-05-17 06:05 AM
Dear Mozra, thanks for your reply.
I tried your code.But counters still don't work. While debugging i can see TIM2's REGISTERS. And also TIM2_CNTRH & TIM2_CNTRL. I check these step by step, and there isn't any count.They are always ''0'' Is it normal? Is it a bug? Also i put a breakpoint in ''void TIM2_UPD_OVF_BRK_IRQHandler(void) interrupt 13'' And program never stopped. What's wrong? :-[ I really need it. It's very important for me! [ This message was edited by: keskintaylan on 19-11-2009 15:39 ]2011-05-17 06:05 AM
Hi,
you can find below an example using Timer2: /* 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 mozra2011-05-17 06:05 AM
Hi everybody.
I have a problem with timers on STM8S103F2. I'm using RIDE. I need UPD/OV interrupt urgently. I tried all of timer examples but i have nothing.Counters didin't work.(on debug screen)They are always ''0''.Interrupt was never occured! PLEASE! give me an example of TIM2 UPD interrupt or tell some tips. Some told that i must edit STM8S.h, but how,where,what? I will be appreciate if answered quickly... Thank you... [ This message was edited by: keskintaylan on 19-11-2009 12:05 ]2011-05-17 06:05 AM
Please & Please:
Send me a full project about TIM2 UPD&OV writing with RIDE. GPIOA.3 must toggle in interrupt routine. Please send with using ''h'' & ''c'' files. And please try yourself, be sure it's working. Very very appreciate who helps. THANK YOU!2011-05-17 06:05 AM
Hi,
Can you please check the status for the PCKEN15 bit in CLK_PCKENR1 this bit should be kept set(reset value)? you can set this bit using: CLK_PeripheralClockConfig(CLK_PERIPHERAL_TIMER2, ENABLE); Regards mozra2011-05-17 06:05 AM
Dear Mozra
While debugging CLK_PCKENR1 = 0xFF; [ This message was edited by: keskintaylan on 19-11-2009 16:39 ]2011-05-17 06:05 AM
Dear Mozra,
I used STVD as you suggest.Yes timer is working.Thank you for your suggest.I guess too that RIDE have issues. But interrupt didn't work. Here is my codes: . . . . 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); } void main(void) { Init_TIM2(); GPIO_Init(GPIOA, GPIO_PIN_3, GPIO_MODE_OUT_PP_LOW_FAST); while(1); } . . . .2011-05-17 06:05 AM
in ''stm8s_it.c''
#include ''stm8s_it.h'' . . . #ifdef _COSMIC_ @far @interrupt void TIM2_UPD_OVF_BRK_IRQHandler(void) #else /* _RAISONANCE_ */ void TIM2_UPD_OVF_BRK_IRQHandler(void) interrupt 13 #endif /* _COSMIC_ */ { //GPIO_WriteReverse(GPIOA, GPIO_PIN_3); GPIO_WriteHigh(GPIOA, GPIO_PIN_3); TIM2_ClearITPendingBit(TIM2_IT_UPDATE); /* In order to detect unexpected events during development, it is recommended to set a breakpoint on the following instruction. */ } . . .2011-05-17 06:05 AM
Hi,
It seems that is an issue with RIDE and is under investigation you can use STVD + Raisonance to avoid temporarily this issue Regards mozra