0
\$\begingroup\$

When it is written that to check if some flag bit is set, you have to look at for example 0x74[2], does that 2 means 3rd bit of register or 2nd? From which number they count in datasheet 0 or 1, how to determine that?

\$\endgroup\$
2
\$\begingroup\$

It is common for register bit numbering to start at bit 0, but there are exceptions. That is why, to be sure of the correct answer for a specific device, you need to read its datasheet:

  • If you see a mention of bit 8 within a byte, then the bit numbering starts from 1
  • If you see a mention of bit 0 within a byte, then the bit numbering starts from 0

Obviously things are more complicated when referring to registers larger than a byte (i.e. larger than 8 bits), but the same principle applies.

Here is an example from a datasheet which you've asked about before:

Extract from ADV7511 Programming Guide [Source]

You can see that in this device's datasheet, a register's bit numbering is from 0 to 7 as highlighted with the red border, so that answers your question about the starting bit number.

\$\endgroup\$
1
\$\begingroup\$

In standard datasheet, Counting of bits in register always starts from 0th bit. Means as per your example the xxx[2] means third LSB bit.

\$\endgroup\$
  • 1
    \$\begingroup\$ Except when reading SAE standard, where they count from 1 to 8. Really depends on the publisher! \$\endgroup\$ – Jeroen3 Jun 23 '17 at 12:08
  • \$\begingroup\$ @Jeroen3,Yes correct! \$\endgroup\$ – Ravi C Jun 23 '17 at 12:10
  • 1
    \$\begingroup\$ If it is a power architecture device, the highest numbered bit is the least significant which can make life interesting. \$\endgroup\$ – Peter Smith Jun 23 '17 at 12:25
0
\$\begingroup\$

By context. Does the document ever reference bit [0] or a register, or bit[32]? Find the table for the full register at some address. This will typically identify all 32 bits with wither a function, reserved, not implemented (and so on).

\$\endgroup\$
0
\$\begingroup\$

Why don't you open the data sheet, go to the page that describes the relevant flags and see for yourself what position they are in the byte(s) they are contained within. It's a lot safer to do this than to expect there to be some generic answer that is always 100% accurate.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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