I have a master burst mode function that sometimes works right but more often does not send the first data byte. Code as follows:
void InitI2C(void) {
//--- Backlight at Addr 0x38, Beeper at Addr 0xF8 ---//
I2CMasterInitExpClk(I2C2_BASE, GetClkSpeed(), I2C_100K); // Master, 100Kbps.
//--- Real Time Clock at Addr 0xD0 ---//
I2CMasterInitExpClk(I2C0_BASE, GetClkSpeed(), I2C_100K); // Master, 100Kbps.
}
void RtcWrite(u8 Register, u8 Data) {
while(I2CMasterBusy(I2C0_BASE)) {} // Wait till done.
I2CMasterSlaveAddrSet(I2C0_BASE, RtcAddr, I2CWrite); // This shifts the addr left 1.
I2CMasterDataPut(I2C0_BASE, Register); //
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_START); // Register.
while(I2CMasterBusy(I2C0_BASE)) {} // Wait till done.
I2CMasterDataPut(I2C0_BASE, Data); //
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH); // Data.
}
The "Register" is 0x02 and the "Data" is 0x01. Sometimes it works correctly:
But more often the Register value is not sent: