AnsweredAssumed Answered

Input capture Porblem

Question asked by mahmoud boroumand on Jul 31, 2017
Latest reply on Aug 1, 2017 by mahmoud boroumand

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?

Outcomes