6
\$\begingroup\$

I have this MIKROE board wired up to an S2 Feather via the SDA and SCL pins. The MIKROE board is powered by the Feather via 3V3 and GND.

I have 2 kΩ pull-up resistors to 3V3 on the SDA and SCL pins. When I don't use pull-ups, I can't detect any devices at all.

I run the following scan:

import time
import board

i2c = board.I2C()

while not i2c.try_lock():
    pass

try:
    while True:
        print(
            "I2C addresses found:",
            [hex(device_address) for device_address in i2c.scan()],
        )
        time.sleep(2)

finally: 
    i2c.unlock()

With NO pullups I get:

I2C addresses found: []

This is strange in itself to me, because normally CircuitPython has a separate error for no pull-ups, but in this case it just returns no addresses. For the longest time I thought the MIKROE board must have built in pull-ups, but I checked the datasheet and it seemed inconclusive.

So I wired it up again as described with the pull-ups and return:

I2C addresses found: ['0x53', '0x5b']

Two addresses isn't the strangest thing in the world, because this device specifically says it responds to two addresses in the datasheet, but as far as I can tell, neither of these match any addresses enumerated in the datasheet. I admit, I don't know how to configure the I2C address using the I2CADDR pins, and maybe that's part of what's going on, but when I run other sketches trying to write to either of those two devices nothing seems to be happening. Is it improperly wired because I added pull-up resistors and are these addresses artifacts? Am I simply misreading the datasheet?

\$\endgroup\$
5
  • 1
    \$\begingroup\$ They both look like the addresses in the datasheet. Page 10 says 0101 0XXXb and 0101 1XXXb, the X values depend on the address configured using the I2CADDR, which I don't know as I can't find the schematics. \$\endgroup\$
    – Puffafish
    Oct 12, 2022 at 15:43
  • 2
    \$\begingroup\$ I expect to get just a blank response without pull ups on the I2C lines as pull ups are required for it to work at the hardware level. So it looks to me like you're getting what it expected. \$\endgroup\$
    – Puffafish
    Oct 12, 2022 at 15:45
  • \$\begingroup\$ @Puffafish, I can't work that out either. So I wasn't entirely sure. If this is expected behavior then I should be able to read/write from/to the Mikroe device wired as-is, yes? \$\endgroup\$ Oct 12, 2022 at 15:47
  • 2
    \$\begingroup\$ Yes. It is perfroming how I'd expect. \$\endgroup\$
    – Puffafish
    Oct 12, 2022 at 15:49
  • \$\begingroup\$ @Puffafish. Thank you! Time to post a different question then. Since the mikroe device wasn't responding to commands to those addresses, I thought the addresses must be wrong, but I see now there is another problem further downstream. Thank you! If you would like to post an answer saying this is expected behaviour (and I misread the datasheet), I will mark this as solved. \$\endgroup\$ Oct 12, 2022 at 15:52

3 Answers 3

9
\$\begingroup\$

The I2CADDR pins are used to set the address of the device.

Some of the bits in the I2C address are not selectable. Those are the 4 MSBs. The 3 LSBs in the address are selectable by HW. The address is given in the datasheet as 0b1010xxx where xxx is the 3 LSB.

Lets take a few examples

  1. 0b1010000 = 0x50
  2. 0b1010001 = 0x51
  3. ...
  4. 0b1010111 = 0x57

The other address granted in the datasheet was 0b1011xxx Lets replace the xxx

  1. 0b1011000 = 0x58
  2. 0b1011001 = 0x59
  3. ...
  4. 0b1011111 = 0x5F

From this you can calculate backwards what I2CADDR0, I2CADDR1 and I2CADDR 2 is.

You found that 0x5B and 0x53 responds.

Lets take a look, 0x5B = 0b1011011 and 0x53 = 0b1010011

From this, we can deduce that:

  1. I2CADDR2 is pulled low
  2. I2CADDR1 is pulled high
  3. I2CADDR0 is pulled high

Regarding the pull ups, you always need those in standard and fast I2C, as it is an open drain topology.

I would guess that the reason for you not getting the usual "no pull ups warning" is because you operate the I2C through an RS232 adaptor. I dont think that one can communicate back that there is no pull ups; but it is a guess.

\$\endgroup\$
2
  • \$\begingroup\$ The address pin setup is seen directly from the schematics so they don't need reverse-engineering. There is also no need to guess about I2C pull-up resistors either, because you can again just look at the schematics and they are there. So no external pull-ups are needed. \$\endgroup\$
    – Justme
    Oct 12, 2022 at 16:29
  • 1
    \$\begingroup\$ OP is actually trying to operate the RS232 through I2C :-) The connection from the Feather to the board uses I2C. I would rather think there was some kind of wiring issue in the first attempt, as the board does have pull ups. \$\endgroup\$
    – jcaron
    Oct 13, 2022 at 17:06
6
\$\begingroup\$

Both two addresses do match the addresses listed in the datasheet.

Even the address configuration pins look like they are working.

The I2C pins do have pull-ups. You need to look at the schematic of the board which uses the chip, not the chip datasheet, as it's not the chip that has pull-ups.

The address select pins A0 and A1 are also pulled up, and A2 is jumpered to ground, so it should just work and everything looks just the way as expected.

\$\endgroup\$
4
  • \$\begingroup\$ I don't currently have anything hooked up to A0, A1, or A2. Am I supposed to connect A2 to ground? \$\endgroup\$ Oct 12, 2022 at 16:13
  • \$\begingroup\$ You are using the PCB module which does have the address pins hooked up for you. Please, look at the schematics of the board which uses the chip and you will see them. You don't need to connect them yourself. \$\endgroup\$
    – Justme
    Oct 12, 2022 at 16:25
  • \$\begingroup\$ I see. Thank you @Justme! \$\endgroup\$ Oct 12, 2022 at 16:27
  • \$\begingroup\$ For reference, the board's schematic is here: download.mikroe.com/documents/add-on-boards/click/… A0 and A1 are pulled high, A2 is by default pulled low but can be switched to high by moving the ADDR SEL A2 jumper from 0 to 1 (which would change the addresses to 0x57 and 0x5f, respectively). The resistors may not be strong enough, or you may just have had a wiring issue in your first setup. \$\endgroup\$
    – jcaron
    Oct 13, 2022 at 17:04
4
\$\begingroup\$

They both look like the addresses in the datasheet. Page 10 says the addresses are 0101 0XXXb and 0101 1XXXb, the X values depend on the address configured using the I2CADDR, which you can apparenlty set with JP3, but I don't know what you've set it to. Page 10 also tells you how to talk to each of those addresses.

I would expect to get just a blank response without pull ups on the I2C lines as pull ups are required for it to work at the hardware level.

So it looks to me like you're getting what it expected.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you sir. I wound up awarding the solved badge to T Anderson because his explanation was so detailed, but I truly do appreciate your insight. As soon as my reputation is high enough to upvote, I'll be circling back! \$\endgroup\$ Oct 12, 2022 at 16:19

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.