What is usage of LI flag in RXv2 and how this LI flag is related to interrupt?
LI flag says long word has been transferred to register. LI flag is not related to interrupts.
In reply to phonetagger:
I'm not exactly sure what is vague about explaining why a flag is triggered.
As FrankL has stated when a long word has been transferred to a register the LI flag is set.
There isn't really any code to give as an example.
" it's bewildering why the RTE and RTFI instructions would set the LI flag to 0."
When you return from an interrupt the LI flag is cleared because upon exit of the interrupt the register may be returning a value.
I hope this answers your question
In reply to Mike Clements:
In reply to Mark Barclay:
The LI flag is used for atomic operations. If you have a variable that is used both in normal and interrupt routines. Then you want to make sure that there is no conflict during changes of the variable.
A simple example is a function to set a bit of the variable that makes sure that the variable is not changed during setting of the bit:
;void setBit(int nr, void * addr)
MOVLI [R2], R3 ;load long value @ addr to R3 and set LI flag
BSET R1, R3 ;set the required bit in R3
MOVCO R3, [R2] ;store the adjusted long value back @ addr and clear LI flag
TST #1, R3 ;check if store is done.
BNZ _setBit ;retry set if failed
if an interrupt occurs between MOVCO and MOVLI, then the LI flag will be cleard by the RTE at the end of the interrupt routine.This clearing of the LI flag indicates that its possible that the value @ addr is changed by the interrupt routine.Checking the value of the source register after MOVCO gives you an indication in changes of the value @ addr.A 0 guarantees that the value @ addr is not changed since the MOVLI instruction.A 1 indicates that its possible that the value @ addr has changed since the MOVLI instruction.
The BSET instruction is already atomic so its actually not necessary to use the MOVLI and MOVCO but other operation will need them.