Jan 23, 2023
06:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan 23, 2023
06:45 AM
Hi,
i'm trying to communiacte with a PMBus device via I2C. For that I need to generate a repeated Start between the address write and consecutive read. I'm using a TC387 with ILLD 1.14 and the following code:
IfxI2c_I2c_Config config;
IfxI2c_I2c_initConfig(&config, &MODULE_I2C0);
const IfxI2c_Pins pins = { &IfxI2c0_SCL_P15_4_INOUT,
&IfxI2c0_SDA_P15_5_INOUT,
IfxPort_PadDriver_cmosAutomotiveSpeed1 };
config.pins = &pins;
config.baudrate = 400000;
IfxI2c_I2c_initModule(&t->i2c, &config);
IfxI2c_I2c_deviceConfig i2cDeviceConfig;
IfxI2c_I2c_initDeviceConfig(
&i2cDeviceConfig,
&t->i2c); /* Device config for Bus of i2c handle */
i2cDeviceConfig.deviceAddress = addr;
i2cDeviceConfig.enableRepeatedStart=TRUE;
IfxI2c_I2c_initDevice(&t->i2cDev, &i2cDeviceConfig);
if (IfxI2c_I2c_write(&t->i2cDev, data, 1) != IfxI2c_I2c_Status_ok) {
return FALSE;
}
if (IfxI2c_I2c_read(&t->i2cDev, data, 1) != IfxI2c_I2c_Status_ok) {
return FALSE;
}
For non-PMBus devices this code works fine with enableRepeatedStart set to FALSE. When its set to TRUE the the program doesn't return from IfxI2c_I2c_write. It hangs in an endless loop at
if (!i2cDevice->enableRepeatedStart)
{
IfxI2c_releaseBus(i2c);
}
else
{
//wait until bus is free
while (IfxI2c_getProtocolInterruptSourceStatus(i2c, IfxI2c_ProtocolInterruptSource_transmissionEnd) == FALSE)
{}
IfxI2c_clearProtocolInterruptSource(i2c, IfxI2c_ProtocolInterruptSource_transmissionEnd);
}
waiting for the transmission end interrupt.
After the write the SDA line stays high while SCL stays low
Any ideas?
Kind regards
1 Reply
Jan 27, 2023
01:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jan 27, 2023
01:26 AM
Hi,
Can you try initiating the subsequent write after the repeated start condition?
Best Regards.