Contents
When to use ACK and Nack in I2C?
You really should read the I2C specification here, but briefly, there are two different cases to consider for ACK/NACK: After sending the slave address: when the I2C master sends the address of the slave to talk to (including the read/write bit), a slave which recognizes its address sends an ACK.
When to use ACK or NACK in serial communication?
If address matches the slave address, slave pull the line low for the ACK. If the line is not pull low by any of the slave, then Master consider it as NACK and sends the Stop bit or repeated start bit in next clock pulse to terminate the or restart the communication.
What is the status of the ACK / NACK bit?
The for loop sends a byte as a series of bits. The last part returns the status of the ACK/NACK bit from the I²C slave. The signals are controlled by setting the port bits (SCL_BUS, SDA_BUS) to eiterh 0 (low) or 1 (high).
When does a slave send an ACK or NACK?
After sending the slave address: when the I2C master sends the address of the slave to talk to (including the read/write bit), a slave which recognizes its address sends an ACK. This tells the master that the slave it is trying to reach is actually on the bus. If no slave devices recognize the address, the result is a NACK.
How does an I2C address match a slave address?
I2C Protocol starts with a start bit followed by the slave address (7 bit address + 1 bit for Read/Write). After sending the slave address Master releases the data bus (SDA line), put the line in high impedance state leaving it for slave to drive the line. If address matches the slave address, slave pull the line low for the ACK.
How does the read / write bit work in I2C?
How the Read/Write Bit Works. I2C has two special ways of working with slaves. The Master can send data to the slave, or it can request data from the slave. After the address bit follows what is called an I2C read/write bit. If the master wishes to receive data from the slave it sends a read bit by bringing the line high.
Are there any problems with I2C slave devices?
There is no consistency in datasheets of I2C slave devices for specifying the device address, and even worse most vendors fail to specify which approach they use, leaving users to figure it out through trial and error.