← index #8721Issue #2396
Off-topic · high · value 1.016
QUERY · ISSUE

Wrong SCL / SDA (MICROPY_HW_I2C0_SCL) for PIMORONI_TINY2040

openby charrochopened 2022-06-01updated 2026-03-19
bugport-rp2

I am trying to get I2C working on my Tiny2040 board. Using the board as a responder in a responder/controller manner. I have some minimal code to set up the board using pin four as SDA and pin five as SCL as described in the GPIO diagrams below:

https://shop.pimoroni.com/products/tiny-2040

I am using https://github.com/epmoyer/I2CResponder/blob/main/i2c_responder.py with a minimal setup code that looks like the following on bus 0:

i2c_responder = I2CResponder(0, sda_gpio=0,scl_gpio=1,responder_address=0x41)
while 1:
    if i2c_responder.read_is_pending():
        i2c_responder.put_read_data(0x2)

And for testing, I tried on bus 1 as well against pin 6 and 7:

i2c_responder = I2CResponder(1, sda_gpio=6,scl_gpio=7,responder_address=0x41)
while 1:
    if i2c_responder.read_is_pending():
        i2c_responder.put_read_data(0x2)

I am using an RPI as a controller executing: sudo i2cdetect -y 1

Now the strange thing is:

  1. I get 0 response on bus 0 (i2cdetect detects no device)
  2. I get a signal on bus one and appear on my RPI (i2cdetect detects the device and I can query the value)

I was perusing the code and saw this:
https://github.com/micropython/micropython/blob/master/ports/rp2/boards/PIMORONI_TINY2040/mpconfigboard.h

#define MICROPY_HW_I2C0_SCL  (4)
#define MICROPY_HW_I2C0_SDA  (5)

Should it not be:

#define MICROPY_HW_I2C0_SCL  **(5)**
#define MICROPY_HW_I2C0_SDA  **(4)**

I tried to recompile the above with the mentioned change without much effect. Any thoughts?

CANDIDATE · ISSUE

stmhal: I2C1 on OLIMEX-E407 board has wrong mapping

closedby BrendanSimonopened 2016-09-06updated 2016-09-19
port-stm32

I have built MP for OLIMEX-E407 board. I have an OLIMEX-OLED board connected to the UEXT connector, which has an I2C interface.

I ported the Olimex OLED python module for linux to MP, but I can't get the OLED to display anything.

First I fixed the I2C mappings on the OLIMEX-E407 port as follows.
-#define MICROPY_HW_I2C1_SCL (pin_B6)
-#define MICROPY_HW_I2C1_SDA (pin_B7)
+#define MICROPY_HW_I2C1_SCL (pin_B8)
+#define MICROPY_HW_I2C1_SDA (pin_B9)

The scan() function works and I can see device 60 on the bus, which is correct.

I am sending commands 0x80, 0xAE to the device. The data sheet says the I2C bus should have
[ Device Adress, Control Byte, 0x80, Control Byte, 0xAE ]
where Control Byte = 0xC0,

however looking at a Logic Analyser capture, I can see the Control Byte being written is 0xC2.
i.e. [ DevAddr, 0xC2, 0x80, 0xC2, 0xAE ] instead of [ DevAddr, 0xC0, 0x80, 0xC0, 0xAE ]

Is this a problem?
Is this potentially a reason why the OLED is not working?

Why/how is the Control Byte generated?

I'm not sure if I'm using DMA mode or not. Is there a way to configure this at run time ??

Thanks, Brendan.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied