ARM memory address access

Publisher:HappyExplorerLatest update time:2016-08-03 Source: eefocusKeywords:ARM Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
1. Access the memory location of the absolute address:

     #define pISR_EINT0 (*(unsigned *) (_ISR_STRATADDRESS+0x74))

     The above statement casts the unsigned integer _ISR_STRATADDRESS+0x74 to a pointer to RAM, which can be accessed using the following statement:

pISR_EINT0 = (int)Eint0_ISR

     To access an absolute address, typecast an integer to a pointer.

2. __irq:

     In order to facilitate the use of high-level languages ​​to write exception handling functions, the ARM compiler has made specific extensions to the exception handling functions. As long as the keyword _irq is used, the compiled function will meet the needs of exception response for scene protection and recovery.

3. Some basic principles for writing interrupt service routines:

     √ Avoid doing floating-point operations in interrupt service routines: A good terminal reading program should follow the principle of being short and effective. Doing floating-point operations in interrupt service routines greatly violates this principle. At the same time, some processors/compilers do not allow floating-point operations in interrupt service routines.

     √ The interrupt service routine cannot have a return value: Therefore, the interrupt service routine is defined as a return type of void, that is: void _irq Eint0_ISR(void);

     √ The interrupt service function cannot pass parameters: so the parameter list is void, that is: void _irq Eint0_ISR(void);

4. Static:

     A static variable is actually a global variable, but it has a scope. It can be used to save the intermediate state of the function where the variable is located during the call of the class, for example:

int cCout()

{

Static int loop = 0;

.......

loop++;

.......

  }

     The value of the loop variable will increase with the number of times the function is called. After the function exits, the value of loop still exists, but loop can only be accessed within the function (function scope), and the memory space of loop will only be allocated and initialized when the function is called for the first time. Each subsequent entry into the function will not allocate static, but directly use the last value. Within a module, a function declared as static can only be called by other functions within the module, and other functions outside the module cannot access it. It is a local global variable.

5. Constant:

     If a variable or object is defined as a constant type, it cannot be updated after the definition (readable but not writable), that is, an initial value must be given to it when defining or describing the type.

     Several points to note:

     √ If const is on the left side of the asterisk (*), then const modifies the variable pointed to by the pointer, that is, the pointer points to a constant; such as: const int *a; or int const *a; These two situations are the same (the position of cost in the variable declarator does not matter). The pointer points to a constant and the content cannot be changed at this time, that is, there cannot be a write operation statement *a=3;

     √If cost is on the right side of the model, cost is used to modify the pointer itself, that is, the pointer itself is a constant; for example: the statement int* const a; indicates that the pointer itself is a constant, but the content it points to is not a constant, that is, a++ is wrong.

     √If there are const modifiers on both sides of the asterisk, such as: const int* const a;, it means that the pointer itself and the content pointed to by the pointer are both constants.

6. Volatile:

     To define a volatile variable, the compiler has a technology called data flow analysis, which analyzes where the variables in the program are assigned, where they are used, and where they are invalidated. The analysis results can be used for optimizations such as constant merging and constant propagation. When the compiler checks that the code does not modify the value of the field, it is possible to provide the cache value of the last access when you access the field, which can improve the efficiency of the program, but sometimes these optimizations will cause problems and are not what our program needs. The characteristic is that the program operates on hardware registers. At this time, the volatile keyword can be used to prohibit these optimizations.

     When to use volatile variables:

     √Hardware registers are usually marked volatile because each read or write to them may have a different meaning;

     √ Variables modified in the interrupt service program for detection by other programs need to be declared volatile; otherwise the compiler may update the variable once and then use the cached value each time without updating immediately;

     √ Flags shared between tasks in a multitasking environment should be marked with the volatile keyword: When multiple threads access a field, the code hopes that these accesses can operate (read) the latest value of the field, and the operation of writing to the variable can be updated immediately; add the volatile keyword to the field, then any request (read/write) to the field will be executed immediately.

Keywords:ARM Reference address:ARM memory address access

Previous article:The concept of ARM code domain and segment
Next article:ARM and 51 MCU communication

Recommended ReadingLatest update time:2024-11-16 13:42

Fire monitoring solution based on ARM
With the rapid development of microelectronics and computer technology, 32-bit high-performance, low-power embedded microprocessors have gradually replaced traditional 8-bit single-chip microcomputers, and the use of multi-threaded and multi-tasking embedded operating systems remains a development trend. At pres
[Microcontroller]
Fire monitoring solution based on ARM
ARM7 LPC2138 digital frequency meter design source code and report
1.1 Design Principle Frequency is the number of times a periodic signal changes within a unit time (1s). If the number of repeated changes of this periodic signal measured within a certain time interval T is N, then its frequency can be expressed as f=N/T. Among them, f is the frequency of the measured signal, N is t
[Microcontroller]
ARM7 LPC2138 digital frequency meter design source code and report
Apple loses orders by switching to RISC-V? Arm: The ecosystem is expected to increase 10 times
Regarding the recent rumors that Apple intends to deploy RISC-V and avoid the Arm architecture, Arm Taiwan President Zeng Zhiguang said on the 7th that he would not comment on a single customer, but emphasized that OEM self-manufacturing of ICs is the general trend and the Arm ecosystem is expected to grow 5-10 times.
[Mobile phone portable]
ADS1.2 uses jlink debugger (debug chip s3c2440 arm9)
1. Software Installation ADS1.2 Download: http://down.drv5.cn/www.drv5.cn/arm-ads1.2.rar Jlink driver download: http://fastsoft.onlinedown.net/down/JLink_Windows_V630d.exe S3C2440led bare metal program (GT2440 development board): https://download.csdn.net/download/u012577474/11249524 Download and install the above 3
[Microcontroller]
ADS1.2 uses jlink debugger (debug chip s3c2440 arm9)
Building a cross-development environment based on ARM and Linux
0 Introduction At present, with the increasing maturity and widespread application of ARM technology, microprocessors based on ARM cores have become the mainstream of the embedded market. The establishment of embedded operating systems for ARM architecture has become a hot topic in current research. Among the m
[Microcontroller]
Building a cross-development environment based on ARM and Linux
Several issues in ARM assembly (general interrupt issues and soft interrupt SWI analysis)
      General interruption problem analysis         After power-on, the ARM CPU will automatically enter SVC mode, which is also the default working mode after ARM is powered on. If an interrupt occurs, ARM will automatically switch to external interrupt mode (IRQ for example). If it is FIQ, it will switch to FIQ mo
[Microcontroller]
ARM9 interrupt controller
Briefly review the control process of the ARM9 interrupt controller: 1. First, the triggered interrupt can be identified (the corresponding interrupt source must be turned on, and then the current interrupt status register is queried). The hardware will control the PC to jump to the interrupt vector entry (IRQ_HANDLE,
[Microcontroller]
ARM9 interrupt controller
Design of wireless network card device driver based on ARM
0 Introduction With the development of mobile and portable communications, wireless local area networks (WLANs) are becoming increasingly popular. The access to wireless local area networks in embedded systems can not only realize wireless control and data transmission of embedded systems, but also meet some spe
[Microcontroller]
Design of wireless network card device driver based on ARM
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号