General discussions about working with the Astrobe IDE and programming ARM Cortex-M0, M3, M4 and M7 microcontrollers.
-
gray
- Posts: 83
- Joined: Tue Feb 12, 2019 2:59 am
- Location: Mauritius
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);
BEGIN
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?
-
cfbsoftware
- Site Admin
- Posts: 467
- Joined: Fri Dec 31, 2010 12:30 pm
-
Contact:
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.