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.

关于I2C能读不能写的问题

Other Parts Discussed in Thread: BQ76920

现在我的TM4C123G开发板已经能够和作为slave的BQ76920进行通信,可以通过I2C读取到slave中各个寄存器的数据,但是不能写数据到slave的寄存器中,这是为什么呢?

写数据的代码如下,还有个问题就是,写数据的时候我想写入0100 0000的话,是直接写64进去吗? 望各位大神斧正

void I2CSend(uint8_t slave_addr, uint8_t reg, uint8_t data)
{
I2CMasterSlaveAddrSet(I2C0_BASE, slave_addr, false);

//specify register to be read
I2CMasterDataPut(I2C0_BASE, reg);

//send control byte and register address byte to slave device
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START);

while(I2CMasterBusy(I2C0_BASE));

I2CMasterDataPut(I2C0_BASE, data);

I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);

while(I2CMasterBusy(I2C0_BASE));

I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_STOP);

}