Application of Serial E2PROM 24LC65 in Single Chip Microcomputer

Publisher:BlissfulDreamsLatest update time:2012-02-18 Source: 国外电子元器件 Keywords:E2PROM  24LC65 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Overview

24LC65 is a serial E2PROM chip with a large capacity at present, with a storage capacity of 8kB, small size, low power consumption, and power-off protection. The AT89C52 microcontroller also has an 8kB internal ROM, and also has the characteristics of low power consumption and strong control function. The microcontroller system composed of the two has low hardware overhead, data can be transmitted serially, and has low power consumption, which is very practical. However, it is more troublesome to write and read programs for 24LC65. This article will introduce the programming method and introduce the application programming of writing and reading 24LC65 that has been passed using the subroutine structure.

2. Connection between 24LC65 and microcontroller
2.1 Pin functions of 24LC65

24LC65 uses an 8-pin DIP package, and the pin functions are as follows:
Pins 1 to 3 (A0, A1, A2) are three-bit address input terminals;
Pin 4 GND is the ground terminal;
Pin 5 SDA is the binary data input and output terminal;
Pin 6 SCL is the clock input terminal;
Pin 7 NC is floating;
Pin 8 VCC is the 5V positive power supply.

2.2 Connection between 24LC65 and microcontroller

The connection circuit is shown in Figure 1. There are 8 24LC65 chips in total. The three-bit address A2, A1, and A0 of the chip are connected into 8 configurations. A2, A1, and A0 are arranged to form 8 chip select addresses. Therefore, up to 8 chips can be selected on two lines, and 64kB storage space can be addressed. Each chip addresses 8kB. Among them, the address range of chip 1 is 0000H~1FFFH, and the address range of chip 8 is E000H~FFFFH. SDA is the serial data input and output line, and SCL is the clock input terminal. Before each access to 24LC65, the I2C data bus operation must be started, and each time the access ends, the I2C data bus operation must also be stopped. The operation timing is determined by the relationship between SCL and SDA. As shown in Figure 2, it can be seen that when SCL is high, the I2C bus is started when SDA changes from high to low, and the bus operation is stopped when SDA changes from low to high. If the bus is started for a read operation, 1 bit of data is read out on the falling edge of the SCL pulse. If a write operation is started, 1 bit of data is written on the rising edge of the SCL pulse.

3. Data Format

The data format for each write operation of E2PROM 24LC65 is composed of 4 bytes. The first byte is:

1

0

1

0

A2

A1

A0

R/W

Among them, A2, A1, and A0 are address bits, R/W is the read-write bit, R/W=1, read E2PROM operation; R/W=0, write E2PROM operation.

The second byte is:

X

X

X

A12

A11

A10

A9

A8

Among them, × is arbitrary, A12, A11, A10, A9, A8 are the high 5 bits of the address of E2PROM 24LC65.

The third byte is the lower 8-bit address A7~A0 of E2PROM 24LC65. The fourth byte is the 8-bit data. Note that each byte is followed by an ACK signal.

4. Write 24LC65 program

The key is to use the instructions of MCS-51 microcontroller to write a subroutine to 24LC65. The main program can be called four times in a row to achieve the purpose of writing a byte of data to 24LC65. Assume that the byte addresses of the bytes to be written in the microcontroller are 6FH, 6EH, ..., 68H, and are stored in the D7, D6, ..., D0 bits of the bytes to be written, respectively, as the entry parameters for calling the subroutine to write a byte. Start by the main program and stop the bus. The programs are as follows:
; The main program starts and stops the bus
SETB P3.1 ; SCL=1
SETB P3.0 ; SDA=1
CLR P3.0 ; SDA=0, start the bus


CLR P3.0
SETB P3.1
SETB P3.0 ; Stop bus operation
; Subroutine to write one byte
MOV C, 6FH ; D7 bit is sent to carry C
CLR P3.1
MOV P3.0, C
SETB P3.1 ; Write D7 bit
CLR P3.1
MOV C, 6EH ; D6 bit is sent to carry C
MOV P3.0, C
SETB P3.1 ; Write D6 bit
CLR P3.1
MOV C, 6DH ; D5 bit is sent to carry C
MOV P3.0, C
SETB P3.1 ; Write D5 bit
CLR P3.1
MOV C, 6CH
MOV P3.0, C
SETB P3.1 ; Write D4 bit
CLR P3.1
MOV C, 6BH
MOV P3.0, C SETB P3.1
; Write D3 bit CLR
P3.1
MOV C, 6AH MOV
P3.0, C SETB
P3.1 ; Write D2 bit CLR P3.1 MOV C, 69H MOV P3.0, C SETB P3.1 ; Write D1 bit CLR P3.1 MOV C, 68H MOV P3.0, C SETB P3.1 ; Write D0 bit CLR P3.1 NOP SETB P3.1 ; Write one byte end CLR P3.1 ; ACK RET












5. Read 24LC65 program

The program for reading 24LC65 includes both write control word and write address operations, as well as read data operations. The write control word and write address operations are the same as the program for writing 24LC65, that is, the first three bytes are the same, except that the bus operation must be stopped after the third byte. The fourth byte restarts the bus and sends the read command. Only the fifth byte is the operation for reading 24LC65. The program for reading 24LC65 is as follows:
MOV R7, #08H
READ: SETB P3.1; read a byte in A
CLR P3.1; shift out a bit
MOV C, P3.0; shift out a bit and pass it to carry C
RLC A
DJNZ R7, READ
SETB P3.1
CLR P3.1; ACK
CLR P3.0
SETB P3.1
SETB P3.0; stop the bus
RET
. The program runs reliably and is highly practical in actual use. If you want to increase the storage capacity, you can select two more I/O lines of the microcontroller and connect eight 24LC65 chips to form another 64kB serial E2PROM.

Keywords:E2PROM  24LC65 Reference address:Application of Serial E2PROM 24LC65 in Single Chip Microcomputer

Previous article:Design and implementation of electronic price-computing scale based on AT89C51 single-chip microcomputer
Next article:Using AT89C2051 to remotely control household appliances

Recommended ReadingLatest update time:2024-11-16 19:42

Read and write operations of the internal E2PROM of PIC
//-------------------------------------------------------- //EEPROM byte write program //Function: write a byte to internal EEPROM //Entry: EEADR = address // EEDATA = data //-------------------------------------------------------- void write_eeprom ( void ) { // while ( WR ) //Wait for the last write operation
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号