On Wed, Jun 5, 2019 at 8:21 AM Dimitrios Chr. Ioannidis via fpc-devel <
fpc-devel@lists.freepascal.org> wrote:

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

In my opinion not required for a normal ISR, since the global interrupt
flag is disabled anyway. Obviously if you enable the global interrupt flag
inside an ISR tor nesting interrupts then you would need the above
functions for atomic access to variables.

For new architectures such as tinyAVR1 or megaAVR0 series the interrupt
systems are a bit more involved (not sure how one would ensure atomic
access if a normal ISR is interrupted by a non-maskable interrupt).
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply via email to