1. Overview
Ordinary 51 single-chip microcomputers can expand ROM and RAM with 64K bytes of space each. In actual applications, external ROM is rarely expanded, and RAM is generally expanded because the internal RAM of ordinary 51 single-chip microcomputers is too small, only 128-256 bytes, which is often not enough when processing large amounts of data. The external expansion of RAM requires the use of P0, P2, P3.6, and P3.7, consuming 18 IO ports, resulting in insufficient IO ports. In order to solve the above contradictions, large-capacity 51 single-chip microcomputers (enhanced 51 single-chip microcomputers) came into being. This type of single-chip microcomputer generally has 1K-16K RAM and 16K-64K ROM built-in, and the price is relatively expensive. In some cases, using ordinary 51 single-chip microcomputers to expand RAM externally can save costs more than directly using enhanced 51 single-chip microcomputers. Therefore, it is necessary to learn how to expand RAM externally on 51 single-chip microcomputers.
2. Circuit Design
On the WSF-51DB development board, 32K RAM (HM62256B) is expanded, and the address latch chip uses 74HC573. If the RAM is expanded off-chip, the P0 port is used as the multiplexed port for the low byte of the data and address, and there is no need to add a pull-up resistor. Of course, adding a pull-up resistor has no effect. It should be noted that when using the off-chip expansion RAM, it is best not to connect other resources to the P0 port and the P2 port. Only 15 address lines are used to access the externally expanded 32K RAM, so P2.7 is used as the enable pin of the address latch 74HC573 and the chip select of the HM62256B. As shown in the figure below, in order to reduce cross-wiring, the 74HC573 is flipped down, which looks a bit awkward.
3. Software Design
/****************************************************** **
*Program name: 51 MCU external expansion RAM test
*Program function: write data to the external RAM, read data from the external RAM, and light up the 8 LEDs of port P1
* Development tools: WSF-51DB development board
* MCU model: AT89S52-24PU
*Clock frequency: 12MHZ
*Program author: Master Wu
*Copyright statement: All rights reserved by Master Wu. Please indicate the source address and author when reprinting.
*************************************************** /
#include
#include
sbit oe=P2^7; //External RAM chip select and address latch 74HC573 enable
unsigned char code ramdata[100]= //define 100 data [page]
{
0,1,2,3,4,5,6,7,8,9,
10,11,12,13,14,15,16,17,18,19,
20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39,
40,41,42,43,44,45,46,47,48,49,
50,51,52,53,54,55,56,57,58,59,
60,61,62,63,64,65,66,67,68,69,
70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,85,86,87,88,89,
90,91,92,93,94,95,96,97,98,99
};
//Delay ms function:
void Delayms(unsigned int t)
{
unsigned int i,j;
for(i=t;i>0;i--)
for(j=120;j>0;j--);
}
//Main function:
int main(void)
{
unsigned char i;
oe=0; //Enable RAM chip select and address latch
for(i=0;i<100;i++)
XBYTE[300+i]=ramdata[i];
//Write 100 data into the off-chip RAM, starting at address: 300
while(1)
{
for(i=0;i<100;i++)
{
P1=XBYTE[300+i]; //Read data from the off-chip RAM and light up the 8 LEDs of port P1
Delayms(500);
}
}
return 0;
}
Previous article:51 MCU Keil C Delay Program
Next article:51 MCU bus timing
Recommended ReadingLatest update time:2024-11-16 14:51
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Motor control circuit, MOS burnt out
- Design of filter module based on combination of single chip microcomputer and FPGA
- How to dissipate heat as a whole on the circuit board while ensuring that it is waterproof as a whole? The main reason is that the MOS tube of the patch generates the most heat and steps up and down the voltage.
- How to solve the problem that H file cannot be opened in IAR
- About MSP430 Common Program Architecture - My Understanding
- [ATmega4809 Curiosity Nano Review] ASF does not support ATmega4809
- EEWORLD University Hall----Principles of Automatic Control Lu Jingchao, Northwestern Polytechnical University
- The problem of combining Arm and Linux
- Bluetooth Protocol Analysis_Protocol Architecture
- How to calculate the power of the power amplifier under drain bias?