The consequences of accessing the effective address of the microcontroller and prohibiting address writing

Publisher:数字行者Latest update time:2017-12-22 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Next, let's look at the consequences of accessing a valid address and writing to a prohibited address.

The purpose of the first program is to store the two data 31H and 11H into two units of the external data memory respectively , but the program uses the two logical units corresponding to the physical space 00 unit of the first memory. As a result, the second data 11H overwrites the first data 31H in the physical address 00 unit of the first memory. The problem explained by this program is that one physical unit of the external memory corresponds to two logical addresses, but it is still just one memory and cannot be used as two memories.

The purpose of the second program is to store data 31H into the physical unit 00 of the second external data storage device, and then use the two logical addresses corresponding to the physical unit to fetch data from the unit respectively. The effect is the same, which means that when accessing a physical unit, any logical address corresponding to the unit can be used.

The purpose of the third program is to write a number 12H to the prohibited unit 0000H. As a result, the data in the valid logical addresses 8000H and 2000H are overwritten, so that the next time the program retrieves data from 8000H and 2000H, the data obtained is 12H instead of the correct data originally stored in the two units.

The following is the running process of the first program:

The first instruction sets the contents of accumulator A to 31H.

The second instruction sets the content of DPTR to 8000H.

The third instruction stores the content of accumulator A, 31H, into the external data memory, 8000H.

(Note: From now on, addresses without explanation refer to the logical addresses of the CPU)

The result is that 31H is stored in physical unit 00 of the first memory.

The fourth instruction is to send data 11H into accumulator A.

The fifth instruction is to send 0C000H into DPRT

The sixth instruction is to store the content 11H in accumulator A in external data memory 0C000H.

In essence, it is stored in the physical unit 00 of the first memory, overwriting the data 31H stored in the physical unit last time. From the running of this program, we can see that it is wrong to try to use the two logical addresses of a physical storage unit as two memories.

Let's look at the second program running:

The first instruction sends data 31H to accumulator A.

The second instruction sends 2000H to DPTR

The third instruction stores the data 31H in the accumulator into the 2000H unit of the external data memory, which is actually stored into the physical unit 00 of the second memory.

The fourth instruction fetches the data in the external data memory unit 2000H into the accumulator. In essence, it fetches the data in the physical unit 00 of the second data memory back to the accumulator.

The fifth instruction is to send data 6000H into DPTR

The sixth instruction retrieves the data in the external data memory 6000H unit back to the accumulator

It can be seen that the essence is also to fetch data from the physical unit 00 of the second memory. The result is of course the same as the last time the data was fetched from the 2000H unit. It can be seen that when the memory is accessed using different logical addresses of the same physical unit, the effect is the same.

Let's look at the running process of the third program:

The first instruction sends data 000H to DPTR

The second instruction sends data 12H into accumulator A.

The third instruction stores the data 12H in the accumulator into the external data memory unit 0000H.

Since the CPU sends the address 0000H, P2.5 and P2.7 are both 0, so that the chip select signals of the two memories are valid, and the address lines A0-A12 of the two memories are low . Therefore, after the CPU sends the write signal, the result is of course the same as the last time the number was taken from the 2000H unit.

It can be seen that when different logical addresses of the same physical unit are used to access the memory, the effect is the same. The valid logical addresses of the physical unit 00 of the second memory are 2000H and 6000H. It can be seen that this write instruction to the prohibited address 0000H destroys the original content of the above-mentioned valid logical address, so we must not use prohibited addresses and invalid addresses in the program.


Keywords:MCU Reference address:The consequences of accessing the effective address of the microcontroller and prohibiting address writing

Previous article:How to expand interface chips
Next article:Design and production of the minimum system of single chip microcomputer

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号