Timers and interrupts

gvi70000
Posts: 1
Joined: Wed Nov 08, 2023 6:46 am

Timers and interrupts

Postby gvi70000 » Wed Nov 08, 2023 6:56 am

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

MicroController
Posts: 1734
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Timers and interrupts

Postby MicroController » Wed Nov 08, 2023 10:12 pm

What's the size of the timespans in question? What accuracy/resolution is required?

Who is online

Users browsing this forum: Baidu [Spider] and 182 guests