Page 1 of 1

Timers and interrupts

Posted: Wed Nov 08, 2023 6:56 am
by gvi70000
Hello,

In my application I need to measure the time between 2 events using 2 photogates. I am thinking at the following scenario:
1. When the first photogate is activated an interrupt is triggered and the timer is started.
2. If for a given amount of time the second interrupt is not triggered raised an error
3. When the second photogate is activated a second interrupt is triggered and the timer is stopped.
4. Calculate the speed based on the distance between photogates, calculate where the object will be aster a given amount of time and consider also the time needed for calculations.
5. Toggle a GPIO after the calculated time.

Questions:
1. How do I link the Timer to the GPIO's configured as external interrupts?
2. Ho can I measure the execution time of a function or a code block?

Thank you for your support,
Ion

Re: Timers and interrupts

Posted: Wed Nov 08, 2023 10:12 pm
by MicroController
What's the size of the timespans in question? What accuracy/resolution is required?