We can say that the program memory stores the soul of the microcontroller, which is the working program. The smallest one may be only 1KB (it can only hold 1024 8-bit data at most, because there are many 2-byte and 3-byte instructions in the actual instructions, so it cannot hold 1024 instructions) and the largest one may be 128KB.
These 8-bit data are either photolithographed in the factory, or burned in at one time, or... use a special tool called a programmer to load the successfully debugged machine code into it, or spend a few dollars to make a download cable like the AVR microcontroller and load these things from the computer into it (perhaps the most attractive feature of AVR). Once it enters the computer's program memory, it cannot be freely rewritten except with the help of the above-mentioned device. When the microcontroller is running, it only reads instructions or fixed data from it, so the program memory is given an alias of "read-only memory", abbreviated as ROM, including EPROM that uses a programmer to write ultraviolet erase content, electrically erased EEPROM and the emerging FLASH ROM; ROM that is written once is only used in batch products with fixed circuits and programs, and they are all the same in actual work.
In actual use, in order to locate the data in the ROM when the microcontroller is running, each 8-bit storage unit actually has a fixed "address", usually expressed in hexadecimal: for example, for a so-called 4K ROM, the address is from 0000H to 0FFFH, (that is, from 0000, 0001...4095). When the microcontroller is running, which address to fetch data from is completely determined by the program itself, and we do not need to intervene. Remember, when the microcontroller is powered on, it goes through a short reset process and immediately turns to the lowest address 0000H of the ROM. There is often a "jump" instruction placed here, which jumps from here to another address in one step: the real starting address of the program, such as 0080H for a 51 machine. Is there only instructions in the ROM and nothing else? ROM is a program memory, which includes certain fixed data required to run the program in addition to instructions. If we require that a certain port of a single-chip microcomputer outputs a value from 00H to FFH (255) that changes in a half-sine wave, 10,000 times per second, then if we force it to calculate one by one according to the formula, it will be beyond its ability. However, we can store the pre-calculated values in ROM and directly retrieve them when the time comes.
When it comes to data storage, it is actually a piece of storage that can access data at any time, that is, a storage that can be read (taken) or written (stored), referred to as RAM. The RAM used in current single-chip microcomputers belongs to static RAM or SRAM, which is different from the memory stick used in computers. As long as you write data into SRAM, as long as the power is not turned off or it is not cleared, the data will be stored there. Computers use dynamic RAM, which needs to be constantly refreshed to save data. Because the amount of information processed by a single-chip microcomputer is much smaller than that of a computer, it has less RAM: from none, 128, 256, ... 1K, 2K to 4K, much less than ROM.
Because in fact, RAM is only used as a temporary storage place for data. Unless image processing requires the storage of a large amount of data, generally for single-chip microcomputers that perform simpler tasks, this much is enough. If it is really not enough, it can only be expanded by adding SRAM such as 6116, 6264, etc. In order to access 8-bit binary numbers in RAM units, of course, the specific location is marked with "address" like ROM. If a single-chip microcomputer has 1K (1024) RAM, its address is also from 0000 to 1024, or 0000H to 03FFH in hexadecimal. It can be seen that the address is the same as ROM. Will it be confused? No, because reading ROM is performed by the program pointer or transfer instruction or table lookup instruction of the single-chip microcomputer, and these instructions will not enter the RAM area. Reading and writing RAM is another data transfer instruction, and it will not enter the ROM area. This is also different from computers. The latter's programs and data are in the memory bar, with different addresses. If they are misplaced, it will cause unpredictable consequences. This memory structure of the single-chip microcomputer is also called Harvard structure.
The RAM mentioned in this article is mainly used to store temporary data in the microcontroller. For example, when measuring temperature with a microcontroller, it measures once per second and displays the average value of one minute (updated once per minute). We first use sensors, amplifier circuits, and A/D conversion to convert the analog temperature into a proportional binary number. Then, once per second, the digital value is sequentially stored in the RAM of the microcontroller through the input port. Then, they are summed up and averaged in pairs (off topic: it is troublesome for the microcontroller to perform "division" operations, but division by 2, 4, 8... is very simple. Use the "right shift" instruction 1, 2, or 3 times). The final value is displayed, and then all 60 storage units are written with 0 to clear the old data, and the cycle will be repeated again next time. In addition, there are several registers in the microcontroller. The number is small but the functions are very important. In addition to temporarily storing data, they can also exchange, process, transmit, etc., as well as record the current state of the microcontroller at any time. The input and output ports also exist as registers with special functions. The specific functions are different, so you can't figure them out by just talking about them. You need to read relevant books.
Previous article:DDS+PLL Frequency Synthesis Technology and Application
Next article:Analysis of SMS design based on TC35i GSM module
Recommended ReadingLatest update time:2024-11-16 19:57
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
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
- NB-IoT and LoraWan technical analysis and prospects
- Which companies are the big manufacturers in the embedded field?
- Small IoT Project - Smart Agricultural Irrigation System
- APROM Data Flash LDROM
- OMRON Counters and Timers
- MSP430FR5969 Learning Experience
- Advantages and Disadvantages of Using MicroPython to Design Embedded Systems
- A must-read list for the electronics industry, with detailed introductions
- Has anyone used the voltage-to-PWM chip GP9101?
- How to realize the timing and timer operation functions of the Dacai serial port screen