This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Writing multiple bytes in one I2C transaction

I'm currently successful in writing a register byte on a PCA9685 device and can control it.

However, I'm trying to use the autoincrement mode, which requires writing of four or more bytes to each channel. I have not been able to get this to work.

My method was to use I2C_MASTER_CMD_BURST_SEND_START for the address byte, then switch to I2C_MASTER_CMD_BURST_SEND_CONT for each additional byte. Then, for the last byte, I would use I2C_MASTER_CMD_BURST_SEND_FINISH instead.  All using ROM_I2CMasterControl after ROM_I2CMasterDataPut.

However, I'm not able to successfully get this working. The Tiva appears to write data to the bus, but the PCA9685 does not recognise it. Currently, I'm without my proper scope so I cannot do a full protocol analysis/serial decode. Is there anything obvious I am missing here? Thanks

  • Hello Tom,

    You can refer to the code in the following link

    http://e2e.ti.com/support/microcontrollers/tiva_arm/f/908/p/339516/1185868.aspx#1185868

    Regards

    Amit

  • Hi Tom,

    your general approach seems right, you might want to post some of your code, especially the initializing of the I2C module.

    Meanwhile for your comparison, here's my code for I2C bulk transfer, perhaps that helps...

    i2cError_t i2c_writeRegister(i2cAddr_t addr, uint8_t reg, uint8_t *buf, uint8_t length) {
    	i2cError_t error = { 0 };
    	uint8_t i;
    	I2CMasterSlaveAddrSet(I2C0_BASE, addr, false);
    	I2CMasterDataPut(I2C0_BASE, reg);
    	I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);
    	while (I2CMasterBusy(I2C0_BASE))
    		;
    	error.value |= I2CMasterErr(I2C0_BASE);
    	for (i = 0; i < length - 1; i++) {
    		I2CMasterDataPut(I2C0_BASE, buf[i]);
    		I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
    		while (I2CMasterBusy(I2C0_BASE))
    			;
    		error.value |= I2CMasterErr(I2C0_BASE);
    	}
    	I2CMasterDataPut(I2C0_BASE, buf[i]);
    	I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
    	while (I2CMasterBusy(I2C0_BASE))
    		;
    	error.value |= I2CMasterErr(I2C0_BASE);
    	return error;
    }

    Cheers

    Janos