I am trying to detect a Hall sensor and count the number of switching events. I can use a pin change interrupt, and once the interrupt is serviced, I want it to be ready to run again.
As I wrote this message, it made my sit down and explain what I was doing, and I realized that
1) The WaitForInterrupt() needs to be in its own task to be able to run autonomously. It is not an interrupt service routine in the manner it could be in C as an "ISR".
2) The task does not automatically restart after reaching the end of execution, the way a C ISR could. It needs a loop within the task to re-wait for the next pin change event.
It was pretty obvious once I cleared my mind and got out of "C" and "ISR" thinking mode.
-Tony
Looping a WaitForInterrupt() independently of the main code
Re: Looping a WaitForInterrupt() independently of the main c
Correct, as your other points.spamiam wrote:WaitForInterrupt() [...] is not an interrupt service routine in the manner it could be in C as an "ISR".
You could, of course, configure the pin for a pin change interrupt and add your own ISR. That would eliminate the need for a task whose only purpose is to await the interrupt.
- Don Kinzer