I2C Write and Read Operations
Performing a Write Operation on I2C Master
- Ensure the
busysignal is low. - Assign
din,command_byte,i2c_slave_addrandnum_bytes, then assert thewritesignal for one clock cycle. - Verify the status of the
busysignal. If asserted, the I2C master sends out the write data to the I2C slave device. - Verify the status of the
write_donesignal. If asserted, thedinis written completely. If you want to issue multiple I2C write, insert newdinvalue afterwrite_doneis high. - After the
busysignal goes low, verifyi2c_arb_lostandi2c_rxaksignals are low. - The write data successfully sent out.
Performing a Read Operation on I2C Master
- Ensure the
busysignal is low. - Assign
command_byte,i2c_slave_addrandnum_bytes, then assert thereadsignal for one clock cycle. - Verify the status of the
busysignal. If asserted, the I2C master reads from thecommand_bytevalue of the I2C slave device. - When
data_out_validsignal is asserted, thedata_outis a valid read data. - After the
busysignal is low, verify thei2c_arb_lostsignal is low, and thei2c_rxaksignal is high.
Performing a Write Operation on I2C Slave
- To send the data back to the I2C master when the master requests
a read from the slave, you must provide the write data on the slave based on
the
command_bytevalue received. - Wait for the
ready_to_wrsignal to go high, then assert thewritesignal for one clock cycle. - Verify the status of the
busysignal. If asserted, the I2C slave sends out the write data to the I2C master. - Verify the status of the
busysignal. The write transfer is complete when thebusysignal is low.
Performing a Read Operation on I2C Slave
- On the slave, wait for the
ready_to_rdsignal to go high due to the I2C master doing a write to the slave, then assert the read signal for one clock cycle. - Verify the status of the
busysignal. If asserted, the I2C slave reads out the data transferred by the I2C master. - Verify the status of the
rddata_validsignal. If asserted, thedata_outis a valid read data. - Verify the status of the
busysignal. The read transfer is complete when thebusysignal is low.
Note: The I2C slave drops the additional byte if the I2C master
sends more than DATA_BYTE_WIDTH/8 bytes of data.