Description
Hi there,
I am working with the MAX32666 on a FTHR2 board. I configured I2C2 as a master like this (simplified for clarity):
MXC_I2C_Init(MXC_I2C2_BUS0, I2C_CFG_MASTER_MODE, 0);
MXC_I2C_SetFrequency(MXC_I2C2_BUS0, MXC_I2C_STD_MODE);
... and tied the 10k pullups to 3.3v using jumper J4 on the FTHR2.
With an oscilloscope I found that the SDA and SCL lines had a maximum of around 2.2v, not the expected 3.3v.
Running through the debugger I found that during the MXC_I2C_Init()
call in i2c_me14.c
a mxc_gpio_cfg_t
is used to configure the SDA and SCL pins. This is hardcoded to use VDDIO as the .vssel
field.
The init call is here:
And the definition of the mxc_gpio_cfg_t
struct is here:
msdk/Libraries/PeriphDrivers/Source/SYS/pins_me14.c
Lines 76 to 77 in 1430a0c
In my main function I added this code to re-initialize the SDA and SCL pins to use VDDIOH after the MXC_I2C_Init()
call, and this does now bring the high level of both lines to 3.3v:
const mxc_gpio_cfg_t i2c2_sda_pin = {
.port = MXC_GPIO1,
.mask = MXC_GPIO_PIN_15,
.pad = MXC_GPIO_PAD_NONE,
.func = MXC_GPIO_FUNC_ALT1,
.vssel = MXC_GPIO_VSSEL_VDDIOH,
.drvstr = MXC_GPIO_DRVSTR_0,
};
MXC_GPIO_Config(&i2c2_sda_pin);
const mxc_gpio_cfg_t i2c2_scl_pin = {
.port = MXC_GPIO1,
.mask = MXC_GPIO_PIN_14,
.pad = MXC_GPIO_PAD_NONE,
.func = MXC_GPIO_FUNC_ALT1,
.vssel = MXC_GPIO_VSSEL_VDDIOH,
.drvstr = MXC_GPIO_DRVSTR_0,
};
MXC_GPIO_Config(&i2c2_scl_pin);
Question: Is this the intended way to use an I2C bus with 3.3v pullups? Is there some more ergonomic config I could do? It seems easy to miss this and then wonder why your pullups aren't pulling all the way to 3.3v. I'm definitely operating under the assumption that I might have missed something here, but if not there might be an opportunity for a slightly cleaner I2C config.
Thanks!