Disabling Interrupts

General discussions about working with the Astrobe IDE and programming ARM Cortex-M0, M3, M4 and M7 microcontrollers.
Post Reply
Posts: 83
Joined: Tue Feb 12, 2019 2:59 am
Location: Mauritius

Disabling Interrupts

Post by gray » Tue Apr 16, 2019 3:26 am

First, let me thank you for your patience answering my barrage of questions. Highly appreciated!

Here's the next... How "atomic" is SYSTEM.PUT as regards interference by interrupts? In particular:

Code: Select all

(* irqICER, irqISER, irqSCBit: the ICER, ISER and bit (a SET) corresponding to the interrupt *)
 PROCEDURE* PutByte*(b: BYTE);
    SYSTEM.PUT(irqICER, irqSCBit);
    txnext := (txin + 1) MOD TxBufSize;
    ASSERT(txnext # txout, Error.BufferOverflow);
    txBuf[txin] := b;
    txin := txnext;
    SYSTEM.PUT(irqISER, irqSCBit)
  END PutByte;
Is the first line a safe way to disable the interrupt?

Site Admin
Posts: 467
Joined: Fri Dec 31, 2010 12:30 pm

Re: Disabling Interrupts

Post by cfbsoftware » Tue Apr 16, 2019 12:43 pm

The code generated by SYSTEM.PUT(irqICER, irqSCBit) is:

Code: Select all

mov      r10, irqICER
mov      r9,  irqSCBit
str      r9,  [r10]
or, depending on the value of irqICER, it could be:

Code: Select all

ldr      r10, [pc+offset]  <Const:0>
mov      r9,  irqSCBit
str      r9,  [r10]
<Const:0>   irqICER
As far as I know that is about as optimal as it could be with the Thumb-2 instruction set.

Post Reply