2010-12-03 02:49 AM
Timer as Counter
2011-05-17 05:17 AM
Dear Karakaya
Can you give me code for counting from CH1?
Regards
2011-05-17 05:17 AM
this is my code for CH1 counting
void TIM4init(void) {/* Time base configuration */
TIM_TimeBaseStructure.TIM_Period = 0xffff;
TIM_TimeBaseStructure.TIM_Prescaler = 0;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM4, &TIM_TimeBaseStructure);
TIM_ITConfig(TIM4,TIM_IT_Update , ENABLE);
TIM4->CCMR1=0x0031;
TIM4->SMCR=0x0057;
TIM_Cmd(TIM4, ENABLE);
}
2011-05-17 05:17 AM
''dont waste your time counting pulses at ETR pin
no matter what I tried I couldnot count ETR pulses - ( there is probably a bug in hardware )
try to count pulses at CH1 of the timer - it works'' there is no bug in hardware, TIM_CH1 and TIM_ETR share the same pin, by default TIM_CH1(i.e. PA0) is mapped to the pin, if you want to use TIM_ETR(i.e.PA15) pin remap the pin by programming AF remap and debug I/O configuration register (AFIO_MAPR) TIM2_REMAP(bits 9 & 8) then your code will work
2011-05-17 05:17 AM
hello ,
I tried to count ETR pulses of TIM3 which is conected to PD2 - it didnot count - I insist that there is hardware bug in the manual it ''doesnot'' say that TIM3_ETR and TIM3_CH1 share the same pin can you please write the code here which couns TIM3_ETR pulses ?2011-05-17 05:17 AM
karakaya.mehmet, u can use TIM2_ETR pin to count pulses by using the remap, and u can not count pulse using TIM3_ETR