Other Parts Discussed in Thread: PCA9534
Tool/software: TI C/C++ Compiler
Hello community,
I am having an issue with my I2C code. In the figure below, I am having an issue with I2C SDA line going high between the bytes. It is still communicating with most of the chips on the i2c (bottom figure), but when I am talking to the PCA9534, the bus hangs as shown in the top figure.
void I2CSend(uint8_t slave_addr, uint8_t * data, uint8_t num_of_elements_to_send)
{
uint8_t i;
// Tell the master module what address it will place on the bus when
// communicating with the slave.
I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, false);
//put data to be sent into FIFO
I2CMasterDataPut(I2C0_BASE, data[0]);
//if there is only one argument, we only need to use the
//single send I2C function
if (num_of_elements_to_send == 1)
{
//Initiate send of data from the MCU
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_SINGLE_SEND);
// Wait until MCU is done transferring.
while (I2CMasterBusy(I2C0_BASE));
}
//otherwise, we start transmission of multiple bytes on the
//I2C bus
else
{
//Initiate send of data from the MCU
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);
// Wait until MCU is done transferring.
while (I2CMasterBusy(I2C0_BASE));
//send num_of_args-2 pieces of data, using the
//BURST_SEND_CONT command of the I2C module
for (i = 1; i < (num_of_elements_to_send - 1); i++)
{
//put next piece of data into I2C FIFO
I2CMasterDataPut(I2C0_BASE, data[i]);
//send next data that was just placed into FIFO
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
// Wait until MCU is done transferring.
while (I2CMasterBusy(I2C0_BASE));
}
//put last piece of data into I2C FIFO
I2CMasterDataPut(I2C0_BASE, data[i]);
//send next data that was just placed into FIFO
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH);
// Wait until MCU is done transferring.
while (I2CMasterBusy(I2C0_BASE));
}
}