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). The address from which the microcontroller takes data when it is running 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 in it, 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. Suppose, we want to output a value from 00H to FFH (255) that changes according to a half-sine wave at a certain port of the microcontroller, 10,000 times per second. 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 retrieve them directly 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 (accessed) or written (stored), referred to as RAM. The RAM used in the current single-chip microcomputer 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 kept there. Computers use dynamic RAM, which needs to be refreshed continuously to save data. Because the amount of information processed by the single-chip microcomputer is much smaller than that of the computer, it has less RAM: from no, 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, so much is enough. If it is really not enough, it can only be expanded by adding external 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 the ROM address. 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 the computer. The latter program and data are in the memory bar, with different addresses. If the position is moved, 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). First, we use sensors, amplifier circuits, and A/D conversion to convert the analog temperature into a proportional binary number. Then, we store the digital values in the RAM of the microcontroller through the input port once per second. Then, we sum and average them in pairs (off topic: it is troublesome for the microcontroller to perform "division" operations. The exception is division by 2, 4, 8... which is very simple. Just 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:FPGA slave and fast loading solution based on CPLD
Next article:Two-wheeled self-balancing electric vehicle designed with ATMEGA16 microcontroller
- Popular Resources
- Popular amplifiers
- MathWorks and NXP Collaborate to Launch Model-Based Design Toolbox for Battery Management Systems
- STMicroelectronics' advanced galvanically isolated gate driver STGAP3S provides flexible protection for IGBTs and SiC MOSFETs
- New diaphragm-free solid-state lithium battery technology is launched: the distance between the positive and negative electrodes is less than 0.000001 meters
- [“Source” Observe the Autumn Series] Application and testing of the next generation of semiconductor gallium oxide device photodetectors
- 采用自主设计封装,绝缘电阻显著提高!ROHM开发出更高电压xEV系统的SiC肖特基势垒二极管
- Will GaN replace SiC? PI's disruptive 1700V InnoMux2 is here to demonstrate
- From Isolation to the Third and a Half Generation: Understanding Naxinwei's Gate Driver IC in One Article
- The appeal of 48 V technology: importance, benefits and key factors in system-level applications
- Important breakthrough in recycling of used lithium-ion batteries
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Future Prospects of UWB Technology
- On the problem of value jump in PMT application
- Use of access/_access function in C language
- [Rvb2601 Creative Application Development] +02 Flowing Light
- Millimeter wave technology: key 5G technology
- "Date in Spring" + Factory Tour
- Allwinner V5 helloworld example (test your entire development environment) --- lindeni V5 development board
- The charger has a glitch problem when it is powered on
- Memory alignment processing for ARM processors
- Some useful information: RVB2601 development board program download automatic operation and OLED screen protection