cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure mytimers as counter in STM8s003f3

IKARA.15
Associate II

Hey guys, i have problem about counters, i have a constanst frequency square wave ring tone signal and this signal have to come to my mcu's input pin and i have to detect it that is ring tone, i think i will gonna do this with counters, i have to open timers for a while and at these times timer try count ticks. B

But i dont know how to configure it and how to add interrupt routines to my codes block. Can u help me ? I found some code below but im not sure about and i dont know how to do.

void TIM1_setup(void)
{
TIM1_DeInit();
TIM1_TimeBaseInit(2000, TIM1_COUNTERMODE_UP, 55535, 1);
TIM1_CCxCmd(TIM1_CHANNEL_1, ENABLE);
TIM1_ICInit(TIM1_CHANNEL_1, TIM1_ICPOLARITY_RISING, TIM1_ICSELECTION_DIRECTTI, 1, 1);
TIM1_ITConfig(TIM1_IT_CC1, ENABLE); 
TIM1_Cmd(ENABLE);
enableInterrupts();
} 

1 REPLY 1
IKARA.15
Associate II

anyone help ??