Error in "bit_is_set" "bit_is_clear" mac

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In debugging, I found that the "bit_is_set" "bit_is_clear macros do an "andi" instruction and return the result. This yields a 0 or a non-zero. But the documentaiton says the macros return a 1 or a 0. The and causes a return of some power of 2 rather than always 1.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Steve,
I'm afraid this is by design. Check out the documentation at http://www.avrfreaks.com/AVRGCC/...
IOMACROS.H
bit_is_set( port, bit ); Returns something != 0, if bit 'bit' in 'port' is set, otherwise 0. Macro.
bit_is_clear( port, bit ); Returns something != 0, if bit 'bit' in 'port' is clear, otherwise 0. Macro.

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Note the !=0 bit. HTH!

E

admin's test signature
 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ernest - you are so right!
MY ERROR was not noticing that the document:

https://www.avrfreaks.net/AVRGCC/...

is in error in describing these macros. It says "result = 1". It should say "result is non-zero"

steve