
Counter using TIM2
Fork of Nucleo_Hello_counter by
Diff: Encoder/CounterInit.cpp
- Revision:
- 4:26948bebef6c
- Parent:
- 3:5c895f9199d6
- Child:
- 5:e1783d6ee885
--- a/Encoder/CounterInit.cpp Tue Sep 29 06:56:28 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -#include "mbed.h" - -void CounterInit(TIM_IC_InitTypeDef counterSet, TIM_HandleTypeDef timer, TIM_TypeDef *TIMx, uint32_t maxcount) -{ - timer.Instance = TIMx; - timer.Init.Period = maxcount; - timer.Init.CounterMode = TIM_COUNTERMODE_UP; //TIM_COUNTERMODE_CENTERALIGNED3 for up/down ... - timer.Init.Prescaler = 0; - timer.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; - timer.Init.RepetitionCounter = 0; - - counterSet.ICFilter = 0; - counterSet.ICPolarity = TIM_ICPOLARITY_RISING; - counterSet.ICPrescaler = TIM_ICPSC_DIV1; - counterSet.ICSelection = TIM_ICSELECTION_DIRECTTI; - -} -