Hi,
when sending data via i2c bus it seems that a short delay between the individual communications is needed.
For example the i2c interface is busy with sending data. Immediately after the i2c interface has finished the transfer
(the last byte has been sent and the interface is idle) a new communication is started. Now a short delay is necessary
before the i2c interface is addressed. Otherwise the i2c interface get stuck and stops working. A soft reset of the interface doesn't help.
The interface then needs to be hard resetted. The delay time is about 2 milliseconds.
Here's is what i'm doing when sending data to the slave.
[...] /// Wait for the master to become ready. drv_i2c2_wait_busy(); /// Master is from now on busy. bo_busy = true; /// Insert delay time. Otherwise the master get stuck. drv_i2c2_delay(COM_DELAY_LOOPS); /// Set working variables. ui8_len = ui8_len; pu8_data = pu8_data; ui32_action = I2C_MASTER_CMD_SINGLE_SEND; ui8_mode = SINGLE_SEND; /// If there is only one argument use the single send command. if(ui8_len > 1) { /// Set action. ui32_action = I2C_MASTER_CMD_BURST_SEND_START; ui8_mode = BURST_SEND; } /// Enable interupts. ROM_IntEnable(INT_I2C2); ROM_I2CMasterIntEnableEx(I2C2_BASE, I2C_MASTER_INT_DATA); /// Tell the master the slaves address and that we want to write data. ROM_I2CMasterSlaveAddrSet(I2C2_BASE, u8_addr, false); /// Hand over the first byte. ROM_I2CMasterDataPut(I2C2_BASE, *(pu8_data++)); /// Start sending data. ROM_I2CMasterControl(I2C2_BASE, ui32_action); /// Wait until the master has finished sending the data. /// NOTE: Sending data is done in the isr. drv_i2c2_wait_busy(); /// Return return (I2C_ERR_NONE); }
The sending of the data is done in the interrupt service routine. A flag signals if the master is busy or idle. When starting a transmission. The flag is set at the beginning of a new transmission and is cleared after the last byte has been transmitted/received.
The the microcontroller runs on 120 MHz. The i2c interface runs in fast mode at 400 kHz and there are one master and three slaves on the bus.
Any ideas what could cause the described behavior?
Regards
Marco