Skip to main content
SBADV.1
Associate
October 22, 2020
Question

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 .

  • October 22, 2020
  • 3 replies
  • 1422 views

..

    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    October 22, 2020

    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..
    SBADV.1
    SBADV.1Author
    Associate
    October 24, 2020

    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);