I2C communication of E2PROM (based on 24LC01B)

  1. Start bit: Idle state when the clock line and data line are both high level. When the clock line is high and the state of the data line changes from high to low, it is the start bit.
  2. Stop bit: Contrary to the start bit, the clock line maintains a high level, and the data line level changes from low to high, which is the stop bit.
  3. Valid data: data is sent between the start bit and the stop bit. When the clock line is low, the data line can be changed, and when the clock line is high, the data on the data line remains stable. During this period, one bit is sent every clock cycle. When sending data, start from the high bit and end with the low bit.
  4. answer:

    The host receives the response: After the host sends the address to the slave, the slave must send a response (confirmation) to the host. Therefore, after sending the address, it is necessary to add another clock cycle to the response bit. During the response cycle, the master (microcontroller) pin is set as input, and the slave (E2PROM) controls the data line. When the clock remains high, the data line remains low Level, the host considers this to be a legal response.

    The host sends a response/no response: When the host reads data from the E2PROM, if the host sends a no response to the slave after reading a byte, the slave will release the data line and stop sending data to the host. If a response is sent, the host continues to read data. The opposite of non-response and response: keep the high level during a response cycle.

  5. Read and write commands: the upper four bits are fixed at 1010, the zero bit controls reading and writing, read as 1 and write as 0. The other 3 bits are address bits. The address of the E2PROM is controlled by A1, A2, and A3. From high to low, they are A3, A2, and A1. If only one E2PROM is used, it is generally grounded to 000.
    Composition of read and write commands
    Read and write commands

     

  6. Reading and writing method: Reading and writing generally involves individual address reading and writing, continuous address reading and writing, please refer to the data manual for details.
  7. Read and write clock cycle size: The clock cycle limits the speed of reading and writing. The maximum read and write cycle of E2PROM used is 400KHZ, so you should pay attention to the cycle size when writing programs.
  8. Storage management of E2PROM:

    The data can be divided into three areas to store the same data, read from the three areas each time, and then compare the similarities and differences of the data to determine whether the data is abnormal. When writing new data to it (overwriting the original data), read one or more times after writing it once, and compare the read data with the data to be stored. If they are different, a malfunction may occur.

    In addition, if you want to store a lot of data, you can store the same kind of data in a continuous area, and set the beginning, data bits, and checksum. It can be judged whether the data is abnormal by comparing the read checksum with the checksum generated by the read data.

  9. Interval between reading and writing data each time: Is there a period of time between two reading operations?
  10. WP write protection: WP is connected to a high level to prohibit write operations (reading is possible), and both low level read and write operations are possible.

Guess you like

Origin blog.csdn.net/qq_36439722/article/details/103733268
I2C