How to interrupt my robotic arm using ISR?

then the critical section is in the wrong place, outside the while loop

It's inside the do-while loop.

(I, too, often get confused when someone uses a do-while.)

Confused. I thought we were talking about the code in reply #17.

But I caught an error I made. I meant, the critical section is inside the while loop. The code to handle the critical section belongs inside the loop, as that is where the value is checked.

We happen to know that the boolean value is represented atomically in this case, but it's fortuitous, not guaranteed.

Your reply #7 looks like a good plan, I just didn't see it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.