1
ADMUX  = ADMUX | _BV(REFS);  // uncompounded bitwise OR
ADMUX |= _BV(REFS0);         // #define _BV(bit) (1 << (bit))
ADMUX |= bit(REFS0);         // #define bit(b) (1UL << (b))
bitSet(ADMUX, REFS0);        // #define bitSet(value, bit) ((value) |= (1UL << (bit)))
sbi(ADMUX, REFS0);           // deprecated assembly? 
ADMUX |= (1 << REFS0);       // shift operator
ADMUX |= (1 << 7);           // bit 7 is named REFS0
ADMUX |= 0b10000000;         // bin
ADMUX |= 0x80;               // hex
ADMUX |= 128;                // dec

*under normal 8 bit Arduino circumstances?

1
  • Comments are not for extended discussion; this conversation has been moved to chat.
    – Nick Gammon
    Sep 29, 2022 at 8:24

1 Answer 1

2

You already got an answer in the comments but, just to make double sure, I tried compiling all these statements for an Uno, and they got all translated into the exact same machine code. Well, almost: I had to do some minor adjustments, which I believe are unrelated to the essence of your question. Just for completeness, I changed the following:

  1. I replaced REFS0 by REFS1: on an Uno, REFS0 is bit 6, and REFS1 is bit 7.

  2. I replaced REFS by REFS1, as the former is not defined.

  3. I #included <compat/deprecated.h>, otherwise I get the error “'sbi' was not declared in this scope”.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.