This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I need to do in atomic way two things:
1. enter LPM3 low power mode and
2. enable interrupts.
I undertand that I can do this by correct setting SR register. My question is: can I do these in one intruction, and it will be truly atomic?
Method A. Direct SR register setting:
C: __bis_SR_register( LPM3_bits | GIE );
That is compiled to spu intruction:
bis #216, SR
Method B. Indirect SR setting by RETI
push #Label_1
push #216
reti
Label_1:
I need to be sure, that the method is correct way of doing this in atomic way.
I am affraid that there might be some hardware hazard (even if I set SR in one instruction) that would result:
a) not entering low power mode, or
b) not enabling interrupts,
c) (only for Method B) there are some side effects of using RETI outside ISR.
Regards,
Piotr
**Attention** This is a public forum