Hi Jeppe,

Στις 2/6/2019 5:46 μ.μ., ο Jeppe Johansen έγραψε:
On 6/1/19 3:37 PM, Dimitrios Chr. Ioannidis via fpc-pascal wrote:

< snip >

  As I'm not a compiler guy, isthe "volatile" intrinsic supported in AVR platform ( I didn't find it in intrinsics unit ) ?

It's supported, but it does not do anything at all. At least not now, and I don't think that will change. All global variable or pointer accesses are considered volatile to my knowledge.

But volatile in FPC does not guarantee any atomic access. So this would need to be by you. If what you need is just atomic access, then simple functions like these generate optimal code:

procedure AtomicWnrite(var value: word; new_value: word); inline;
var
  b: Byte;
begin
  b:=avr_save;
  value:=new_value;
  avr_restore(b);
end;

function AtomicRead(var value: word): word; inline;
var
  b: Byte;
begin
  b:=avr_save;
  AtomicRead:=value;
  avr_restore(b);
end;

Can I use those inside an interrupt handler ? What about nested interrupts ?

regards,

--

Dimitrios Chr. Ioannidis

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to