Use SREG in DUE

Hi. I'm using Arduino DUE and trying to control Quadrature Encoder with DC motor.
What I want to code is get shaft degree with my other skatch.
For that reason, I tried SREG but DUE can't use SREG.
Is there any other function that I can use?

Here is my code

void loop()
{
** uint8_t oldSREG = SREG;**
** cli();**
** Pos = encoderPos;**
** SREG = oldSREG;**

** if(Pos != oldPos)**
** {**
** Serial.println(Pos, DEC);**
** oldPos = Pos;**
** }**
** delay(500);**
}

interrupts() and noInterrupts() ?

(I really don’t know, my Due is gathering dust)

This could be interesting.

Replacement for AVR libc ATOMIC_BLOCK macros, now for DUE and other platforms.

The Arduino DUE has 2 hardware quadrature decoders.

There are example sketches in the DUE sub forum to use them for position or speed measurement.

See e.g. this thread, replies #84 to #87: