cancel
Showing results for 
Search instead for 
Did you mean: 

I am using STM8S005K . connected external input to Timer channel 1 . I want to use Timer 1 channel 1 as counter and want to count pulses coming on Timer 1 channel 1 pin . I am using STM8S library functions. Please share sample code .

SBADV.1
Associate II
 
3 REPLIES 3

Perhaps you can Google some of the functions and parameters here, or grep the library source/examples?

Might need to set up the TIM in a maximal count mode.

I'm not using these parts, check the data sheet for specific pin utilization

GPIO_Init(GPIOC, GPIO_PIN_1, GPIO_MODE_IN_PU_NO_IT);//PC1(TIM1_CH1)

TIM1_TIxExternalClockConfig(TIM1_TIXEXTERNALCLK1SOURCE_TI1,TIM1_ICPOLARITY_FALLING, 0x0f);//(TIM1_CH1)

TIM1_Cmd(ENABLE);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thank you I have done some changes in you mentioned code and it starts working . thanks

My code is as follows

GPIO_Init(GPIOC, GPIO_PIN_1,GPIO_MODE_IN_FL_NO_IT );//PC1(TIM1_CH1)

TIM1_TIxExternalClockConfig(TIM1_TIXEXTERNALCLK1SOURCE_TI1,TIM1_ICPOLARITY_RISING, 0x00);//(TIM1_CH1)

TIM1_Cmd(ENABLE);

it is start working but the counter resets to intermittent value and never counts upto 65535.

can you please tell me what could be the reason