septillion-git / arduino-pinchangeint

Automatically exported from code.google.com/p/arduino-pinchangeint
0 stars 0 forks source link

[Question] #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I really don't know if this is the right place to ask, but its the best i could 
see so please forgive me.

I'm just curious if something like this is possible with pinchangeinterrupts 
too:

  noInterrupts();
  // critical, time-sensitive code here
  interrupts();
  // other code here

if so, where can i read about how to do it?

Original issue reported on code.google.com by I.Punish...@gmail.com on 5 Aug 2013 at 8:23

GoogleCodeExporter commented 8 years ago
Absolutely. This is easy:

uint8_t oldSREG = SREG;
cli(); // disable interrupts
(do some stuff here)
SREG = oldSREG; // Restore register; reenables interrupts

...Make sure that when you're doing stuff, if you have a return() or something 
else that takes you out of your code stream early, that you make sure you 
always restore the SREG redister.

Original comment by m...@schwager.com on 11 Aug 2013 at 12:17