2017-09-06 01:11 AM
Hello
I use STDPERIPH_DRIVER .I want Counting a pulse and when it arrive to special number (100 Rising edge) I get an interrupt.How can i do that?
I do somthing like that
TIM_ICInitStructure.TIM_Channel = TIM_Channel_4;
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);
TIM_ITConfig(TIM3, TIM_IT_CC4, ENABLE);
TIM_Cmd(TIM3, ENABLE);
void TIM3_IRQHandler(void)
{if (TIM_GetITStatus(TIM3, TIM_IT_CC4) == SET)
{ TIM_ClearITPendingBit(TIM3, TIM_IT_CC4); time_counter++; if (time_counter == 100) {}
}It work but when i use some mcu they wrok synchronization but after 7 or 8 hours they are not
synchronization and have random delay between them.
Solved! Go to Solution.
2017-09-06 01:44 AM
Don't interrupt on every edge.
Use it as an external clock (TIMx_TS=0b101, TIMx_SMS=0x111), set TIMx_ARR to the required number of repetitions (you used 100 above) and then set interrupt to kick in upon update.
I don't use the 'libraries' so don't know how to do this using their functions, but 'external clock' should be a good starting point to search.
JW
2017-09-06 01:44 AM
Don't interrupt on every edge.
Use it as an external clock (TIMx_TS=0b101, TIMx_SMS=0x111), set TIMx_ARR to the required number of repetitions (you used 100 above) and then set interrupt to kick in upon update.
I don't use the 'libraries' so don't know how to do this using their functions, but 'external clock' should be a good starting point to search.
JW