Interface design of flash memory AT29C040 and single chip microcomputer

Single chip microcomputer STM32L151CCU6
1206RGB (single)
Test - lowercase jpg
Kaixin micro test
Test probe P100-M3

1 Introduction

Since the first flash memory was introduced in 1984, flash memory has been widely used and developed with its EPROM's programmability, EEPROM's electrically erasable performance, and online rewritable features. With the improvement of manufacturing processes and materials, the advantages of flash memory over EPROM and memory such as EEPROM, SRAM and DRAM are becoming more and more obvious.

Atmel introduced a new generation of high-capacity flash memory AT29C040 in 1998. Due to its Fowler-Nordheim tunneling technology, the programming current is reduced by an order of magnitude compared to the first generation of flash memory. The chip only requires +5V power and supports paging programming. In addition, it also has other functions such as hardware data protection, software data protection, data query and bootstrapping module. According to the author's usage, this paper briefly introduces the structural characteristics and usage methods of AT29C040 flash memory, and illustrates the interface and usage of AT29C040 and MCU with a test instrument developed by the author as an example.

2 chip introduction

2.1 chip structure and characteristics

The structure of AT29C040 is similar to SRAM. It has 8 data lines (D0~D7), 19 address lines (A0~A18), 3 control lines (/OE, /CE, /WE), and power and ground lines. The pins are labeled as shown.

The AT29C040 flash memory has the following features:

(1) Powered by a single 5V power supply, the same power supply is used for read and write operations, eliminating a 12V programming power supply VPP;

(2) No additional erase operation is required before programming. During programming, the erase operation is automatically performed inside the chip;

(3) Each time a sector of data is written in a single programming cycle, programming time is greatly reduced. The sector programming time of the AT29C040 is 10ms, while the programming time of other sectors is several hundred ms;

(4) The small sector capacity reduces the requirement for system memory resources when writing data;

(5) Software Data Protection SDP (Software Data Protect) function. In order to avoid human error or system power-on, power-down and other factors caused by the flash memory write operation, AT29C040 set the software data protection function. The principle is that before writing to the flash memory, a three-byte command code must be sent in a certain order before the data can be written, otherwise the data cannot be written.

2.2 chip operation

2.2.1 Read and write operations

The read operation of the AT29C040 is very simple, similar to SRAM, and will not be described again. Here mainly discuss the method of writing to it. First, in the system RAM area, a data image of a sector is generated for the AT29C040, that is, the data to be written is first put into the RAM, and then the three-byte command code is sent to the AT29C040; then the data previously placed in the RAM is transferred. Go to the sector specified by the AT29C040; finally wait for the write cycle time (10ms) of the flash memory to write data to the memory. Its "write" operation timing is shown in the figure.

2.2.2 Data Polling

During the programming cycle, if the last loaded byte is read, the complement of the loaded data will appear on I/O7. Once the programming cycle is over, the true data on all output lines is valid and the next programming cycle can begin. Data polling can begin at any point in the programming cycle, as shown in Figure 3. In the figure, the meaning of each time parameter is: tDH is the data hold time; tOEH is the OE signal hold time; tWR is the write signal recovery time.

2.3 Software Data Protection

Software data protection is accomplished by writing three special data to two special addresses in a series. Turning off software data protection is also done by writing six special data to two special addresses in a series. If you do not perform such an operation, access to the 29C040 will not work properly. The software protection algorithm can be turned on or off by the user. Figures 4 and 5 are flow diagrams of software protection and software protection shutdown, respectively.

Other features of the 29C040 chip and some related parameters are described in detail in the chip manual, which will not be described here. The following is an introduction to its application.

3 interface with the microcontroller

3.1 Hardware Design

The AT29C040 and microprocessor interface are simple and basically similar to the data memory we often expand. The difference is that since it is equivalent to 8 ordinary 64k bytes of RAM, the upper 3 bits of the address are controlled by 3 processor address lines, and the access range is 0 0000 to 7 FFFF. The interface is as shown.

In the hardware design, the microprocessor used by the author is 80C51. Due to the large number of extended chips, a 138 decoder is not used in the chip selection of each device, but a programmable logic device (PLD) is used. In Figure 6, when 29C040 is selected, the state of P13, P14 is 00, and the selected ROM and RAM are 01 and 10 respectively (for simplicity, it is assumed that the expansion chip is only the above).

3.2 Software Design

After mastering the main features of the chip, its use is relatively simple. Below we provide a hexadecimal number 0X45 written to the C language program in 29C040.

#include

#include

Void delay(unsigned int l_time);

Void protect();

Void select_segment(unsigned char seg);

Unsigned char data cdat;

Void write_data(unsigned int m_addr,unsigned int s_sector,unsigned int acount);

{

Unsigned int data addraa, addrbb; /* addraa is the memory address, addrbb is 29C020 address */

Unsigned int data i,j;

Bit data flaga;

Flaga=EA;

EA=0;

Addraa=m_addr;

Addrbb=s_sector*256;

For(j=acount;j>0;j--)

{

Protect();

For(i=0;i<256;i++)

{

P14=0; P13=1;

Cdat=XBYTE[addraa];

Select_segment(s_sector/256);

/*s_sector is an integer multiple of 256*/

XBYTE[addrbb]=cdat;

P14=0; P13=1;

Addraa++;

Addrbb++;

}

S_sector++;

Delay(1000);

}

P14=0; P13=1;

EA=flaga;

}

/* Select 29C040 segment address (high address),

Seg is the segment address*/

Void select_segment(unsigned char seg)

{

Switch(seg)

{

Case 0: P1=0x00; _nop_(); break; /* 29c040 a18a17a16= 000 00000-0ffff */

Case 1: P1=0x01;_nop_(); break; /* 29c040 a18a17a16= 001 10000-1ffff */

Case 2: P1=0x02;_nop_(); break; /* 29c040 a18a17a16= 010 20000-2ffff */

Case 3: P1=0x03;_nop_(); break; /* 29c040 a18a17a16= 011 30000-3ffff */

Case 4: P1=0x04;_nop_(); break; /* 29c040 a18a17a16= 100 40000-4ffff */

Case 5: P1=0x05;_nop_(); break; /* 29c040 a18a17a16= 101 50000-5ffff */

Case 6: P1=0x06; _nop_(); break; /* 29c040 a18a17a16= 110 60000-6ffff */

Case 7: P1=0x07;_nop_(); break; /* 29c040 a18a17a16= 111 70000-7ffff */

}

}

Void protect()

{

Select_segment(0);/* must be written to the 0th paragraph*/

XBYTE[0x5555]=0xaa;

XBYTE[0x2aaa]=0x55;

XBYTE[0x5555]=0xa0;

P14=0; P13=1;

}

Void delay(unsigned int l_time)/* Delay after writing a sector*/

{

Unsigned int data lp;/* 4ms */

For(lp=0;lp

_nop_();

}

Main()

{

Unsigned int data i;

P14=0; P13=1;

For(i=0;i<256;i++)

{XBYTE[0x0200+i]=0x45;}

Write_data(0x0200,0,1);

Delay(1000);

While(1);

}

4 Conclusion

The application of the AT29C040 in the microcontroller not only enables the user to quickly achieve the required functions, but also provides an easy way to store and update the program and data as the flash memory device becomes larger and larger. As voltages get lower and lower, and support for common interface standards, flash memory hardware interfaces and software design will become easier.

references:

[1] Sun Hanfang, Xu Aiqing. Principle and application of MCS51/96 series single chip microcomputer [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 1988.

[2] Yu Yongquan. Principle and Application of ATMEL FLASH Microcontroller [M]. Beijing: Publishing House of Electronics Industry, 1997.

[3] Dou Zhenzhong. Practical Handbook of Peripheral Devices of Single Chip Microcomputer————Memory Volume [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 1998.

[4] AT29C040 data sheet.

[5].AT29C040datasheethttp://

[6].EPROMdatasheethttp://

[7].80C51datasheethttp://

[8].P13datasheethttp://

[9].29C020datasheethttp://

Incremental Encoder

Motion Control Sensor is an original part that converts the change of non-electricity (such as speed, pressure) into electric quantity. According to the converted non-electricity, it can be divided into pressure sensor, speed sensor, temperature sensor, etc. It is a measurement, control instrument and Parts and accessories of equipment.

Incremental Rotary Encoder,Incremental Optical Encoder,Incremental Shaft Encoder,Absolute And Incremental Encoder

Changchun Guangxing Sensing Technology Co.LTD , https://www.gx-encoder.com