Linux IIC Subsystem Analysis (1) - Introduction to AT24C02 Chip

Now many places have applied to the eeprom memory chip, mainly because its storage space is getting bigger and bigger, and the price is getting cheaper and cheaper. It is very necessary to learn the IIC subsystem of Linux and understand the operation mode of the IIC chip.

The AT24C02 chip features and pin function definitions can be directly viewed in the Datasheet. I only pay attention to the device address and operation method, we can operate it knowing these in the actual application.


1. AT24C02 address


The first four bits (1010) are fixed, A2, A1, A0 are related to the hardware connection, 1 when the external input voltage is high, and 0 when the external voltage input is low. A2, A1, A0 in my development board are all grounded, so my device address is 10100000 or 10100001. The last bit of R/W is the read and write bit, which is 0 for read operation and 1 for write operation. For the linux IIC system, the read-write bit driver will be automatically added, and the actual device address bit is the high seven-bit 1010000B, which is 0x50.


2. AT24C02 write operation

The write operation is divided into one byte write and paging write, and the timing is as shown in the figure below.


One byte write sequence: send start signal -> send device address -> wait for ACK -> send address to be written -> wait for ACK -> send value to be written -> wait for ACK -> send stop signal.

The paging write timing is basically the same as writing a byte, except that the stop signal is not sent after the first data to be written is sent, and the data continues to be sent until the stop signal is sent after the data is sent.

Special attention should be paid to the page operation of EEPROM here. In 24C02, the storage space is 2048bit = 256*8bit = 256 Byte, and it is divided into 32 pages, each of which is 8 Bytes. When performing page operations, the lower three bits of WORD ADDRESS are used to represent the address in the page, and all other high bits represent the page address. For example, WORD ADDRESS = 1001B, which means the first address of page 1. Now if you write 8 values ​​to the storage address of 1001B: 1, 2, 3, 4, 5, 6, 7, 8, when the value 7 is written, the first page is full, then 8 will be written to the first The 0 address position of a page. At this time, the information at the 0 position of the first page will be overwritten.


3. AT24C02 read operation.

The read operation is divided into: read from the current address; random address read; continuous address read;


Parse:

Current address read: The data word address inside 24c02 will save the last read or written storage address. When the current address read is executed, the data word address counter + 1 address is read. The main thing is needed here, the address flip will occur at the end of the page, and the first byte data of the page will actually be read. Same as above mentioned also in write operation. The value stored in the data word address will be lost when the power is turned off.


Random Address Read: Note the Dummy Write in Figure 11 above. Random read actually changes the value of the data word address in the eeprom by writing an address, and then reads the current address.


Read continuously:

Continuous reading is started by current address reading and random address reading. As long as eeprom is given a response signal, its data word address will increase, and the master can continue to read data until the data word address is increased to the end of a page, and then Returns to the starting address of the page. The transmission ends when the IIC stop signal is received.


Finally, the eeprom also has a WP control pin. When this pin is low, data can be read and written normally. when the pin is high. eeprom enters write-protected mode. At this time, the data cannot be written.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324764706&siteId=291194637