Replies: 2 comments
-
You can disable and enable interrupts during critical phases of your code. See https://docs.micropython.org/en/latest/library/machine.html?highlight=disable#machine.disable_irq |
Beta Was this translation helpful? Give feedback.
0 replies
-
These docs discuss the issues involved with concurrency. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am wondering what kind of “atomicity” there is in the treatment of regular MicroPython instructions and interrupt callbacks. Let's say I want to print out or modify the contents of an array:
Is there any chance that an IRQ will modify the contents of
myarray
while in thefor
loop (I believe the answer is yes)? What about during theprint()
call?What are the best practices when manipulating arrays which might potentially be modified by IRQs? Should I make a copy of such an array first, as in:
myarray_copy[:] = myarray[:]
, presuming that such a single line of code will be treated as “atomic” (non-interruptable)?Beta Was this translation helpful? Give feedback.
All reactions