Skip to main content
Visitor II
October 24, 2020
Question

Timer 1 counter resets intermittently

  • October 24, 2020
  • 2 replies
  • 644 views

I want to use count external pulses count coming on Timer 1 channel 1 .

I wrote following code. the couter starts counting as I apply external pulses.

but the counter doesnot go upto 65535 value. it gets reset intermittently.

I want to use counter to count incoming pulses continuously and also want to use its overflow interrupt. My code is as below. Please advice me how can I resolve the issue.

GPIO_Init(GPIOC, GPIO_PIN_1,GPIO_MODE_IN_FL_NO_IT );

 TIM1_DeInit();

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

 TIM1_Cmd(ENABLE);

    This topic has been closed for replies.

    2 replies

    Graduate II
    October 25, 2020

    Im not expert for STM8, but maybe your MCU make watchdog resets and you see it as timer resets...

    Visitor II
    November 5, 2020

    maybe try calling

    TIM1_TimeBaseInit(0, TIM1_COUNTERMODE_UP, 65535, 1);

    That way you explicitly set the max count to 65535.