2017-07-31 04:55 AM
Hey
I use stm32f030p4 and i want counting a external frequency (Learning remote ).
I configure timer and interrupts like this
TIM_ICInitStructure.TIM_Channel = TIM_Channel_1;TIM_ICInitStructure.TIM_ICPolarity = TIM_ICPolarity_Rising;TIM_ICInitStructure.TIM_ICSelection = TIM_ICSelection_DirectTI;TIM_ICInitStructure.TIM_ICPrescaler = TIM_ICPSC_DIV1;TIM_ICInitStructure.TIM_ICFilter = 0x0;TIM_ICInit(TIM3, &TIM_ICInitStructure);/* Enable the CC2 Interrupt Request */TIM_ITConfig(TIM3, TIM_IT_CC1, ENABLE);/* Enable the TIM1 global Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;NVIC_InitStructure.NVIC_IRQChannelPriority = 0;NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;NVIC_Init(&NVIC_InitStructure);uint32_t now =0;
void TIM3_IRQHandler(void)
{if(TIM_GetITStatus(TIM3, TIM_IT_CC1) == SET){TIM_ClearITPendingBit(TIM3,TIM_IT_CC1);
now=TIM_GetCapture1(TIM3);
}
}
Interrupt work good but
TIM_GetCapture1(TIM3) is always 0 .
how can i solve this problem?
Solved! Go to Solution.
2017-07-31 07:29 AM
i dont use tim_cmd(tim3,enable)
That's why the timer is not running, i.e. TIM3_CNT is always 0. So then of course if you capture it (i.e copy CNT into CC1) then you always capture 0.
JW
2017-07-31 05:06 AM
Is TIM3 actually running (enabled in TIM3_CR1.CEN and TIM3_ARR nonzero)?
JW
2017-07-31 07:19 AM
Hey i use the STM32F0xx_StdPeriph_Examples and interrupt work well in rising edge. and i dont use tim_cmd(tim3,enable)
2017-07-31 07:29 AM
i dont use tim_cmd(tim3,enable)
That's why the timer is not running, i.e. TIM3_CNT is always 0. So then of course if you capture it (i.e copy CNT into CC1) then you always capture 0.
JW
2017-08-01 02:00 AM
Thanks