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.

low power modes.

hello,

what is the difference between 

    _BIS_SR(LPM3_bits + GIE);        &

    _BIS_SR(LPM3+ GIE);      

please reply

thank you.    

  • LPM3 is defined like this in the header files:

    #define LPM3 _BIS_SR(LPM3_bits) /* Enter Low Power Mode 3 */

    The idea is that it should be used as a statement rather than an expression:

    LPM3; // Enters LPM3 (GIE is not set)

    In your second example above, _BIS_SR(LPM3+ GIE); becomes _BIS_SR(_BIS_SR(LPM3_bits)+ GIE); after preprocessing, which is probably not what you want. I think the general advice is to stick to the syntax used in your first example, since that allows GIE to be set at the same time as entering the low power mode.

  • Hello,

    thank you for the answer.

    But, I did not understand the reply properly. Only i got to know is first statement is valid. But i did not get the difference

  • As Robert Cowsill showed, LPM3 should be defined to _BIS_SR(LPM3_bits), i.e. it is to be used like a function, which is ultimately why the second line of code should produce an error, as it is expanding to: _BIS_SR(_BIS_SR(LPM3_bits) + GIE).

    So if you really wanted to use "LPM3" you could do something like the following to achieve _BIS_SR(LPM3_bits + GIE). 

    __enable_interrupt();
    
    LPM3;

    I would suggest not doing it this way however, since as you discovered it isn't particularly clear.

**Attention** This is a public forum