Portenta H7 Integrated Charger MAX17262

I have a Li-Po battery connected to the Portenta H7 but the charging current is very low (200mA).

Any existing script or Library to program the chip MAX17262 via I2C to modify the charging current?

The existing Library “SparkFun_MAX1704x_Fuel_Gauge_Arduino_Library” compiles but it does not detect the chip.

5.2µA 1-Cell Fuel Gauge with ModelGauge m5 EZ and Internal Current Sensing

6.4 Battery Connector

The Portenta H7 is compatible with a single cell Li-Po or Li-Ion battery (3.7V, 700mAh minimum) connected via a 3-pin BM03B-ACHSS-GAN-TF connector. Battery management is performed by the PF1550 IC.

6.4.2 Battery Charger Specifications:

– Supports single-cell Lithium Ion/Lithium Polymer batteries
– Linear charging (10 mA to 1500 mA input limit)
– Programmable charge voltage (3.5 V to 4.44 V)
Programmable charge current (100 mA to 1000 mA)
– Programmable charge termination current (5.0 mA to 50 mA)

P.S.: Table 48. Constant current charge settings

Yes, there is a PMIC onboard! This one has the charging unit connected.
Connecting a second external charger in parallel to onboard PMIC does not sound a good idea.

And for the PMIC programming, how PF1550 IC is configured - meanwhile other threads out there.
(or I can send you how I program PMIC, but without to enable charging - I guess).
I2C_PMIC.c (6.3 KB)

Great, thanks for all the info, now it's clear how the PF1550 manages the charging current.
Can you please send me the <I2C_PMIC.h> as well?

In the meantime, I have tested this script, but it doesn't work, why?

<#include <Wire.h>
#define I2CDev  Wire1

byte DADR = 0x08; // PF1550 I2C Address
byte reg = 0x8E; // Charger current control register
byte setting = 0x0E; // Setting for 800mA

void setup(){
  Wire1.begin(DADR);
  Wire1.write(reg);
  Wire1.write(setting);
  Wire1.end();
}

void loop(){
  
}

I2C_PMIC.h (822 Bytes)

I guess: you do two separate I2C write transactions:
is this Wire1.write(reg); correct? I would assume you need a single I2C write with register address AND the value setting to write. I guess, you need a byte array with two entries: reg and setting and write these two bytes.
Potentially, you just address a register in PMIC but without to write the value.

My function doing an I2C register write looks like this:

int I2C_Write(uint8_t slaveAddr, uint8_t* bytes, size_t numBytes) {
	/* an I2C write, also used to write registers */
	I2CDev.beginTransmission(slaveAddr);
	I2CDev.write(bytes, numBytes);
	I2CDev.endTransmission();
	return numBytes;
}

The bytes is an array with at least two entries: register address and value to write.
ATTENTION: even it is actually possible to write consecutive registers, e.g. bytes has register address plus N values - the PMIC does not support consecutive! You can only read and write one single register in chip.

You can find this config also on the published bootloader code:
Portenta H7 bootloader
See in "app/power" the power.cpp files.

I'm still not able to make it work.
Can you also send the *.ino file how you initialize?
Why you don't call the function HAL_I2C_MspInit() in your script?
I have included this inside the function I2C_PMIC_Initialize():

// Constant current charge to 800mA
data[0]=0x8E;
data[1]=0x0E;
I2C_PMIC_Write(PMIC_I2C_SLAVE_ADDR, data, sizeof(data));

But I still have a charging current of 200mA.
Where is the issue?

I have sent you my code file just for reference (to see which registers in PMIC are written).
This file is NOT part an Arduino sketch, not for Arduino IDE: it is my stand-alone Cube32IDE project.
Sure, you cannot call this function because I2C would not be initialized.
I do in my main.c

int main(void)
{
	//PMIC configuration - as earliest as possible
	I2C_PMIC_Setup();
	I2C_PMIC_Initialize();

I am not sure if you can do it in a similar way: this is for a bare-metal project. Your Arduino sketch will do a lot of stuff, e.g. configures the PMIC, the MCU clocks etc. Here in my project I do it right after Reset_Handler - nothing really configured yet.

Try to use the original Wire.write() functions, in your Arduino .ino.
My code is for a full stand-alone project, not Arduino sketch. Use the info in it as: which registers in PMIC are written with which value. Do not try to use this code (not sure if it can work in an Arduino sketch).

You can also try to read back the registers, to very (or use a scope to see the I2C signals).
Best is to read all the register in PMIC first and have it as golden reference before you change anything.
There are two register regions to read: 0x00 ... 0x6F and 0x80 ... 0x9F. The second block are the charger registers: in datasheet: they start at offset 0x80 and register 0x0E (becomes 0x8E) is the current setting register - correct.

I guess, you call my functions but they are not initialized.

OK I managed to make it work in Arduino!
I had to slightly modify your script and initialize the functions, that's it.

Portenta_I2C_PMIC.zip (2.7 KB)

Now I have a measured charging current of ~700mA, which I'm assuming is being regulated by the PMIC, limited to 800mA, as I wanted.

The only thing missing is the LED Indicator for Charging, I checked the registers and values, all correct, but still not ON, any ideas?

The orange charging LED is controlled by register 0x1C and 0x1E (0x9C, 0x9E with the offset 0x80).
Default is: SW mode and switched off.
Potentially you had to enable it, enable the LED driver, the PWM (brightness) and blinking frequency.
No idea, but I know the LED is switched off (in SW mode). When I play with register 0x9E I can switch the LED on. This LED is on as default: so, if your board is bricked, the PMIC not configured (no FW/Bootloader running in MCU) - you see the orange LED on.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.