nickgammon / SendOnlySoftwareSerial

Arduino library for sending (only) of serial data
32 stars 13 forks source link

sei() might be missing #3

Open schmmi opened 3 years ago

schmmi commented 3 years ago

SendOnlySoftwareSerial line 168 disables interrupt. However interrupts are not enabled again. Probably sei() is missing at the end of the function.

nickgammon commented 3 years ago

See line 196:

  SREG = oldSREG; // turn interrupts back on

The technique of saving the status register and restoring it is a standard method of turning interrupts back on.

If we used sei() as you suggest, and they were not on anyway then we have now changed interrupts from not on to on. The method of saving and restoring SREG makes sure that the interrupts are back the way they were beforehand.