I have a question about using I2C with the Portenta H7. My sensor is the HMC5883L. I have it hooked up to +5V from the Portenta H7, and I hooked up the SCL, SDA, and GND lines accordingly. While my sensor has pull-up resistors incorporated onto the module, my question is about adding my own pull-up resistors.
Logically speaking, since my sensor is being powered by +5 volts, I should put a 4.7k-ohm resistor between the SCL/SDA lines and +5 volts. However, looking at the Portenta H7 schematics, the STM32H747 microcontroller seems to run at +3.3 volts. With the processor running at that voltage, is it safe to connect my 4.7k-ohm resistors to +5 volts or would that damage the processor?
No, not safe. Yes, damage. You need a voltage level translator circuit. But the Adafruit module includes that. In your case, simply power the module VIN from 3.3V instead of 5V, and all the pull up resistors will now be connected to 3.3V. But you will have to short VIN to 3.3V on the regulator IC U2. That will effectively convert the module for use with 3.3V only.
Another way, remove resistors R1, R3 and add external pull up resistors to 3.3V. Supply the board with 5V as it is designed.
I didn't examine the board layout, but it might be possible to cut the 5V supply to R1,R3 and jumper that to 3.3V, instead of removing the resistors.
In my haste, I did not check to see if the H7 has 5V tolerant I2C pins... it might...
Thanks. Darn, I really screwed that up. All of the I2C sensor tutorials had it wired to +5 volts. I thought it would be fine with the Portenta H7. I could just remove my external pull-up resistors and not worry about the ones that Adafruit has on their module, and that would solve all problems. That way, the module can be safely powered from +5 volts.
....is there a way to run diagnostics on the Portenta H7, to make sure that it is working alright?
Well, the ones that Adafruit has on the module, are connected to 5V. So not really correct for a 3.3V processor. I don't know about diagnostics. I don't think it would help in this case.
Really, the brutally simple solution is to put a level translator between the module and the Portenta. Then no mods needed.
Are you connecting to the pins called "I2C 3V3" on the Portenta schematic?
Edit - oh I see it now! Jumper the 5V to the 3.3V pin on the magnetometer board. Power both pins from 3.3V. It will work fine on 3.3V that way, and interface properly to a 3.3V processor.
I'm not sure. I was connecting it to the I2C pins on the GPIO headers on the side of the Portenta H7 (D12 and D11). According to the Portenta schematic, that's on the Form Factor MKR block (page 8), which goes to I2C3. From there, I'm not sure.
Yes, that would work if I powered everything from 3.3 volts (hooking up to the 3.3 volt pin on the Portenta and the magnetometer). But, on a board that I routed, I used 5 volts instead of 3.3 volts, and my external pull-up resistors (not on the magnetometer) went from SCL/SDA to +5 volts. This was something that I'm trying to examine after the fact, in order to see what I shouldn't do in the future.
You sent a board to production without prototyping it first?
Anyway, to convert the Adafruit module to 3.3V operation, supply 3.3V to both the 3.3V and the 5V pin. I have no idea about your "routed" board, so I can't help you fix that. Perhaps you can modify it with jumpers.
No amount of testing can give you sufficient confidence when you exceed some specification, unless you are the manufacturer, with access to all the proprietary detailed information.
If you roll out a device that has 5V signals on a 3.3V limited pin, it will work or not work, but you will never be able to guarantee that it will continue to work.
One place you could intervene, is where the module pins meet the board. You could cut and re-route the 5V pin to the module, so it goes to 3.3V instead.
Again, I don't have the time now to check the Portenta input specs, but you could remove R1-R4 entirely, and apply only 3.3V to pin 1 and pin 3 on your J2. That would enable the 3.3V pull up resistors on the HMC.
If you used this circuit on the Every, it's also wrong.
I appreciate the assistance, but my board followed the aforementioned schematic. Yes, I definitely screwed up with the external pull-ups, but at least the solution is to just remove them and let the Adafruit sensors do its thing. I'm just freaking out about whether or not I damaged the Portenta or not doing this.
By definition, you have. Unless the inputs are 5V tolerant, long term operation of the part is far from guaranteed. Even a single application of overvoltage can cause latent damage.
I was talking about the PCB layout, not the schematic... but you can also modify the module instead. Cut the 5V pin and jumper 5V to 3.3V on the header.
You can't safely run with the solution you've proposed because the module has its own pull up resistors connected to 5V...
Here's my PCB layout. It doesn't do much good now since it's already been made. Sorry, we switched to the LSM9DS1, but nevertheless, the schematic still remains the same, and we're using Adafruit's module. Right, looking at the schematic for Adafruit's module, both 3.3V and 5V have pull-ups. If powering from 5-volt, Adafruit has a regulator which steps down the 5V to 3.3V, so you can safely power the module with 5V or 3.3V. In this case, R1-R4, external to the Portenta and Adafruit sensor, screw everything up.
True, the sensors also have external pull ups. However, the sensor has a regulator to go from 5 to 3.3V. So, the sensor can be powered by 5 volts or 3.3 volts. It has pull-ups on both voltages. According to their description, the I2C SCL/SDA pins are level-shifted allowing for 3-5 volt logic. I think this level shifting is done with the BSS138 MOSFETs. With this, it should be fine to use 5-volt logic or 3.3-volt logic, but it didn't take into account my added on pull-ups. That's what concerns me.
Ok. So, let me try and rephrase. The Portenta is running at 3.3-V logic. The description on Adafruit's page is as follows:
I2C Pins
SCL - I2C clock pin, connect to your microcontrollers I2C clock line. This pin is level shifted so you can use 3-5V logic, and there's a 10K pullup on this pin.
SDA - I2C data pin, connect to your microcontrollers I2C data line. This pin is level shifted so you can use 3-5V logic, and there's a 10K pullup on this pin.
With the on-board level shifter, it should be fine to POWER the module from 3.3 volts or 5 volts, correct? If that's all, it's just a matter of removing R1-R4.
You can not supply 3.3V to a 3.3V regulator. There has to be some voltage differential. The result of doing that, would be a reduced output voltage, like say 2.5-3.0V. The only way to power the module from 3.3V is via the 3.3V pin that is provided. But if you only do that, it's not enough because it won't allow the level shifter MOSFETs to do their job. That is why I told you to strap the 3.3V and 5V pin on the module. If you just left 5V disconnected, the resistors would be in a strange configuration that might not play well with I2C..
It doesn't happen often, but in this case Adafruit documentation is absolutely incorrect (or, to be more generous - incomplete).
The regulator is bypassed when supplying 3.3 volts externally. If powering with 3.3V, you wouldn't be supplying 3.3V to the regulator. On the schematic, VIN is +5 volts while VDD is +3.3 volts. If +5 volts isn't supplied, the 3.3V regulator is off. So, when supplying 3.3V to the module via the correct pin, you bypass the regulator.
Okay, for the first time you are acknowledging that you have to power the module from 3.3V. But there is more you need to do, which I already outlined above.
The SCL/SDA lines coming from the module are connected to 5V on the module via pull up resistors. If that is not connected to anything, what you get is a series combination of R2,R4 = 20k ohms right between SCL and SDA. I don't know about you, but that makes me feel uncomfortable. It means that if one is pulled low, the other can also be pulled partly low. Also possibly backfeed current through the regulator. Not good.
VIN and Vdd are adjacent on the module connector so it's a simple wire jumper to connect them. Providing 3.3V to both, you would have to solve however you like. I would cut the 5V trace coming from the Portenta, and jumper between that and the Portenta's 3.3V pin which is two pins down the row. That way you can still retain the bypass caps you have in there.