1. memory location for accessing the absolute address: # Define pisr_eint0 (* (unsigned *) (_ isr_strataddress + 0x74) The preceding statement forcibly converts an unsigned integer _ isr_strataddress + 0x74 to a pointer and points to ram, use the following statement to access it: Pisr_eint0 = (INT) eint0_isr To access an absolute address, convert an integer to a pointer.2. _ IRQ: To facilitate the compilation of exception handling functions in advanced languages, the arm compiler makes specific extensions to the exception handling functions, as long as the keyword _ IRQ is used, in this way, the compiled functions meet the needs of abnormal responses for on-site protection and recovery; 3. Some basic principles for writing interrupt service programs: √ avoid floating point operations in interrupt service programs: A good terminal reader program should follow the principle of short and effective, floating-point operations in interrupt service programs are far from this principle. At the same time, some processors/compilers do not allow floating-point operations in interrupt service programs; √ The interrupt service program cannot return values. Therefore, the interrupt service program defines the return type as void, that is, void _ IRQ eint0_isr (void ); √ The interrupted service function cannot pass parameters. Therefore, 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 in which the variable is located, such: Int ccout () { Static int loop = 0; ....... Loop ++; ....... } The value of the loop variable will increase with the number of function calls. After the function exits, the loop value still exists, but the loop can only be accessed in the function (function scope ), loop memory space will be allocated and initialized only when the function is called for the first time. It will not be allocated for static every time you enter the function, the previous value is used directly. In a module, a function declared as static can only be called by other functions in this module. Other functions outside the module are not authorized to access it. It is a local global variable. 5. Constant: When a variable or object is defined as a constant type, it cannot be updated after the definition (readable and writable). That is, an initial value must be given to the variable or object when defining or describing the type. Several notes: √ If the const is on the left side of the asterisk (*), the const modifies the variable to which the pointer points, that is, the pointer points to a constant; for example, const int * A; or Int const *; the two conditions are the same (cost is not related to the location of the variable Declaration). The Pointer Points to a constant. At this time, the content cannot be changed, that is, there cannot be a write operation statement * A = 3; √ If cost is on the right side of the model, cost is to modify the pointer itself, that is, the pointer itself is a constant; for example, int * const A; the statement indicates that the pointer itself is a constant and the content to be pointed to is not a constant, that is, a ++ is incorrect. √ If the left and right sides of the asterisk have const modifier, for example, const int * const A;, the pointer itself and the content pointed to by the pointer are constants. 6. Volatile: Defines a volatile variable. The compiler has a technology called data stream analysis. It analyzes where variables in a program are assigned values, where they are used, and where they are invalid. The analysis results can be used for constant merging, constant propagation and other optimizations. When the compiler detects that the Code does not modify the value of a field, it is possible that the cached value of the last access is provided when you access the field, which can improve the program efficiency, however, sometimes these optimizations cause problems, which are not required by our program. They are characteristic of the program that operates the hardware register. In this case, you can use the volatile keyword to disable these optimizations. When using the volatile variable: √ Volatile is usually used for hardware registers, because each read/write operation may have different meanings; √ Volatile Declaration must be added to the variable modified in the interrupt service program for other programs to detect; otherwise, the compiler may not update the variable immediately after each update; √ The voatile keyword should be added to the logo shared by all tasks in a multi-task environment: when multiple threads access a field, the Code wants these accesses to be able to operate (read) to the latest value of the field, the operation that writes data to the variable can be updated immediately. If the volatile keyword is added to the field, any request (read/write) to the field will be executed immediately. |