cancel
Showing results for 
Search instead for 
Did you mean: 

TIM1 counter

mateuszficek
Associate
Posted on March 08, 2012 at 20:57

Hello,

I try

measure

frequency

50-500Hz. I use STM8S-DISCOVERY KIT with STM8S105C6T6 and FWLib. How

initiate

the appropriate

timer and

which port

to use

?

#include ''stm8s_conf.h''
#include ''stm8s.h''
#include ''stm8s_it.h''
#include ''stm8s_tim1.h''
#include ''stm8s_gpio.h''
void
init(
void
);
void
GPIO_app_init(
void
);
void
TIM1_app_init(
void
);
main()
{
init();
enableInterrupts();
while
(1)
{
TIM1_SetCounter(5); 
tim1freq = TIM1_GetCounter();
}
}
void
init(
void
)
{
GPIO_app_init();
TIM1_app_init();
return
;
}
void
GPIO_app_init(
void
)
{
}
void
TIM1_app_init()
{
TIM1_DeInit();
TIM1_TimeBaseInit(31, TIM1_COUNTERMODE_UP, 65535, 0)
TIM1_CounterModeConfig (TIM1_COUNTERMODE_UP);
//TIM1_ICInit(TIM1_CHANNEL_1,TIM1_ICPOLARITY_RISING,TIM1_ICSELECTION_DIRECTTI,TIM1_

2 REPLIES 2
Nickname13136_O
Associate II
Posted on March 13, 2012 at 13:24

Pls refer STM8S105C6T6 datasheet and STM8S-DISCOVERY KIT  UM for proper selection of GPIO.

Regards,

mateuszficek
Associate
Posted on March 13, 2012 at 19:29

In this way?

what

to do next

,

to measure

frequency (50Hz- 500kHz)

.

void GPIO_app_init(void)
{
GPIO_DeInit(GPIOC);
GPIO_Init(GPIOC, GPIO_PIN_
1
, GPIO_MODE_IN_FL_NO_IT);
}