2013-09-06 06:35 AM
I'm trying to measure time between two pulses on a pin. Time between pulses is in 10 - 100 uS range so I can't use millis function. What I'm trying to do is use TIM2 CNT register. Since my APB2 clock is runnig at 32MHz I should get a resolution of about 0.03 uS.
The problem is that when I try to debug the CNT register is always at 0x0000 value :( I use this code to initialize timer: void Enable_Timer() { RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); TIM_InitStructure.TIM_Period = 0xFFFFFFFF; TIM_InitStructure.TIM_Prescaler = 0x0000; TIM_InitStructure.TIM_ClockDivision = TIM_CKD_DIV1; TIM_InitStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM2, &TIM_InitStructure); TIM_Cmd(TIM2, ENABLE); } And this to read the CNT value: tt= TIM_GetCounter(TIM2); EDIT: I am using STM32L152 board #timer #discovery #stm32l #tim2013-09-12 04:58 AM
I couldn't find any information regards to PB10 channel in reference manual. Where did you find it?
That would be thehttp://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00277537.pdf
for the part.