enabling/disabling interrupts in assembly

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
v923z
Posts: 168
Joined: Mon Dec 28, 2015 6:19 pm

enabling/disabling interrupts in assembly

Post by v923z » Mon Nov 13, 2017 7:44 pm

Hi all,

In a critical section of my code, I have to toggle a couple of pins in assembly, because speed/accuracy is essential. I have separated this part of the code in a single function (I don't care about the overhead of calling the function), and decorated it with @micropython.asm_thumb

But this is useful only, if absolutely no interrupts occur while the function is being executed. I can, of course, call disable_irq() and enable_irq() immediately before, and after the function, but this is not particularly elegant, and even worse, prone to errors. I think it would be much better, if I could enable/disable the interrupts in the function that is decorated. What would be the assembler equivalent of the two above-mentioned functions?

Thanks,

Zoltán

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: enabling/disabling interrupts in assembly

Post by Roberthh » Mon Nov 13, 2017 8:23 pm

Look here on the use of cpsie() and cpsid():
http://docs.micropython.org/en/latest/p ... _misc.html

v923z
Posts: 168
Joined: Mon Dec 28, 2015 6:19 pm

Re: enabling/disabling interrupts in assembly

Post by v923z » Mon Nov 13, 2017 8:44 pm

Robert,

Thanks for the pointer!

Zoltán

Post Reply