This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I need to measure the time elapsed between two interrupts, I'm using CPUTimers but I have five GPIO interrupts to handle but there appear to be only 3 CPUTImers. Any suggestions to measure all of them?
Thank you,
Biagio
Hello Biagio,
What you can do is use the same CPU timer, but just measure the delta and have separate global variables for each. If you know which interrupts will trigger in what order, you can have a variable for the timer count and another for the delta from the last interrupt, and then have this for each set of ISRs. The variable for the timer count for each ISR can be used to calculate the delta.
Best regards,
Omer Amir
Hi Omer,
Thanks for reply. Yes, that's what I was thinking to do, but I'll have to deal with the timer reset after X seconds reaching the maximum allowable value of uint32_t, am I wrong?
Regards,
Biagio
but I'll have to deal with the timer reset after X seconds reaching the maximum allowable value of uint32_t, am I wrong?
Yes, that is true if you're just letting it continuously run. However, if you expect the time intervening between all 5 interrupts to be within that time (2^32 clock cycles x System Clock speed), and you know the order in which the interrupts should trigger you can reset the timer after it reaches the last interrupt in the sequence (or at the moment you think the timer should be reset).
If this is not the case, you could just have a conditional to check if the delta is negative, and in that case calculate the delta via the overflow.
Hi Omer,
the interrupts are independent, I can reset the timer when all the connected functions are deactivated, but there may be a case where I need to go into free run. So I will have to check the negative delta and be sure that the time elapsed between two interrupts never exceeds 2^32 clock cycle otherwise this solution no longer works.
Thank you,
Regards,
Biagio