Announcements

Equip yourself to optimize AURIX™ MCUs for Evs at the EV Webinar. Click here to register.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

AURIX™ Forum Discussions

ntimm
Level 1
Level 1
Welcome! First question asked

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

ntimm_0-1674484859676.png

Any ideas?

 

Kind regards

0 Likes
1 Reply
Nambi
Moderator
Moderator
Moderator
First like given 25 likes received 50 solutions authored

Hi,

Can you try initiating the subsequent write after the repeated start condition?

Best Regards.

0 Likes