I'm struggling to convert some code I have working on an Arduino Uno over to a Raspberry Pi Pico. The program is some simple I2C control code for a TM1680 LED Driver IC that I put together based upon the technical documents. As mentioned, the code works perfectly when the IC is connected to the Arduino Uno, but when exactly the same program is recompiled for the Pico nothing happens, (i.e. no LEDs turn on/off). The IC is detected by the Pico over I2C, both by this code and a separate scanner program and the address is correct.
For both boards I'm using the same code written in the Arduino IDE. For the Pico I'm recompiling the working Uno program, using the 'Arduino MBed OS RP2040 Boards' plugin (v4.0.4). The recompiled code uploads to the Pico without issue and can detect the I2C IC I'm trying to control. I know this from the return signal values I receive when sending command messages to the IC.
The IC is powered from an external source, with only the I2C lines and a grounding pin being connected to either board. The I2C is pulled up to 3.3V by resistors, while the IC is powered from a 5V rail. The grounding pins are all connected together in a single circuit. No modifications are made to the circuit besides a direct swap of the pins connected to the Arduino to the Pico, (i.e. SCL/SDA and GND). The Arduino/Pico boards are powered either by USB (when connected to a computer) or from the external power source (another USB connection not linked to a computer).
I have used other I2C ICs (e.g. MCP23017, AT42T1070) that I programmed for projects in the past using this method. Never before have I encountered an issue with the code not working once transferred from the Arduino to the Pico, so after trying everything I can think of to debug and resolve the issue I now find myself stumped.
I've included the relevant code below. Can anybody think of a reason I've overlooked as to why when on the Pico the IC becomes unresponsive, yet works fine with an Arduino?
If the led chip runs at 5V, then it might expect that the SDA and SCL are 0V or 5V signals.
Is there a English data sheet ?
A low level is between 0 and 0.3 VDD.
A high level is between 0.7 VDD and 5V.
0.7 * 5 = 3.5V
Since the Raspberry Pi Pico is a 3.3V board, the SDA and SCL can only reach 3.3V.
A working scanner and not-working code is normal. There might be different timing that influences the voltage levels.
The Arduino Uno has a input filter and a output slew-rate limiter for SDA and SCL. It still works, even if the I2C bus is not perfect.
Please take the time to actually read the question before writing unhelpful comments that have absolutely no practical use or value. Also perhaps consider what you're writing before posting.
Why is this a surprise to you? These are two totally different processors, and in no way are even supposed to be code compatible.
Yes I'm aware they're 'totally different processors' which is why I specifically stated I was recompiling the code, for use on the RP2040, used in the Pico, (also the Arduino Nano). As said, I am using the dedicated plugin provided by Arduino for their IDE specifically designed for that processor.
The Wire library, (which is the only library being used in my example code) is compatible with both processors. Additionally, many are in fact designed to be code compatible, which is why there are far fewer programming languages in this world than there are microprocessors.
Then you have not done much of this sort of thing with the Pico. Only trivial examples will work.
I have far more experience using the Pico than you seem to believe. As mentioned, I have successfully transferred far more complex programs than this over for other ICs in the past. I'm not sure how any of that is relevant to this issue. Additionally, I personally consider an I2C program using only one library and designed to control a single IC to be trivial.
There is no official English data sheet unfortunately. The best translated version I've been able to find is on a GitHub project created by a group writing control programs for other ICs in the TM16XX family, (but unfortunately not the TM1680). The URL is:
I'm ashamed to say I missed that... Thanks for pointing it out. I'll try adding a Logic Level Converter in to boost the power to 5V and see if that makes a difference.
I wasn't aware of this. Is there any documentation of how I might replicate this functionality for the Pico, either through hardware or code? If possible, it sounds like it might be useful for a later stage of the project I'm working on.
The Arduino layer is on top of Mbed for the Raspberry Pi Pico. You are using the latest version, so that is allright.
The Arduino layer on top of Mbed is for a number of processors. The specific extras for the Pico are called the "variant": https://github.com/arduino/ArduinoCore-mbed/tree/main/variants/RASPBERRY_PI_PICO.
The "variant" is mostly a few definitions and the Arduino layer on top of Mbed is actively maintained. It should be pretty good.
However, the compatibility can be seen as a "goal", especially for the Wire library.
What if the timing is too fast on the Pico ? Thank you for the link to the English datasheet. I see no timing problems, but you could add a delay of 1ms at the end of "sendMessage()" for a test.
Grumpy_Mike responded maybe a little rough, but we deal with problems on this forum. When you state that the Wire library is compatible with both processors and that some things are not relevant, then we start pointing at our screens and laughing really hard
Let's hope that it is just voltage levels and/or timing. If it is something else, then it might be very hard to fix.