2016-01-12 01:06 PM
How do you recognize, which edge lead to EXTI, if it is configured for rising and falling edges?
Now, I look a state of that pin in IDR register, immediately when EXTI occurs. But in that time, between cause of interrupt and my reading, pin could already be toggled. Is there any other, more secure way?Thanks2016-01-12 01:40 PM
Use a TIM?
2016-01-12 01:55 PM
Set active only one edge, in interrupt change the edge, after that you can check if state is changed to eliminate VERY short pulses.
2016-01-12 09:39 PM
@clive: How do you think that I should use TIM? Don't understand?
@dembek.radoslaw: You thought that I make interrupt with let say rising edge, then stop program inside of interrupt routine, force pin back to 0 (to GND) and see if value in IDR register has changed to 0, too?2016-01-12 11:37 PM
What dembek is trying to say is: set exti to trigger on rising edge.
In the interrupt, check the signal. If it is high, you just got a simple rising edge, change exti to do falling edge next. If the signal is low, you just got a short pulse, leave exti at rising edge triggering. Do the same for the falling edge.2016-01-13 04:11 AM
@clive: How do you think that I should use TIM? Don't understand?
Review the manual?ONE pin, for either CH1/CH2 or CH3/4 pairing, configure the time base in a maximal mode, and then the paired channels (Direct + Indirect) to input capture the time stamp of opposite edges of the same input, and interrupt.For high rates use DMA to capture the edge time stamps.2016-01-13 12:42 PM
But what would I know then, if I capture time stamps of two consecutive opposite edges?
What I want to know is, which edge triggered an EXTI, if EXTI is configured on rising and falling edge.2016-01-13 12:48 PM
I tell you how to do it, with ensurence to detect corect edge.
2016-01-13 01:19 PM
FFS
You'd use a TIM in place of an EXTI, you'd get both edges, they would flag different interrupts, and the time of arrival would be time stamped. Pretty much any case where you look at the EXTI source via the state of the GPIO pin, or toggle the edge causing the interrupt, you have the potential for a race condition if the frequency is high, the pulse is glitchy in nature, or you've got an IRQ with some long latency.2016-01-13 01:20 PM
YOU: Is there any other, more secure way?
ME: Use a TIM