Embedded skills: Introduction to three interrupt debugging methods of ARM

Publisher:science56Latest update time:2012-04-10 Source: 赛迪网 Keywords:Embedded Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Embedded Software Development Process

Refer to the embedded software development process. Step 1: Project creation and configuration. Step 2: Edit source files. Step 3: Project compilation and linking. Step 4: Software debugging. Step 5: Execution file solidification.

In the whole process, users first need to create a project and make preliminary configurations for the project, including configuring the processor and debugging equipment. Edit the project files, including the assembly and C language source programs written by the user, as well as the link script files that need to be written when compiling the project, the storage area image files and command script files that need to be written during the debugging process, and the startup program files for the program running entry during power-on reset.

It is important to understand the last four files, and their functions are explained below.

(1) Link script file: It is effective when the program is compiled. This file describes the information related to the code link positioning, including code segment, data segment, address segment, etc. The linker must use this file to correctly locate the code of the entire system. The link script files for debugging programs in SDRAM, debugging in FLASH, or running after solidification should be distinguished. (Use the extension *.ld in the IDE development environment)

(2) Command script file: It is effective when debugging a program in SDRAM. When the integrated environment is connected to the target, during software debugging, and after the target board is reset, the integrated environment is sometimes required to automatically complete some specific operations, such as resetting the target board, clearing the watchdog, masking the interrupt register, and memory area mapping. These operations can be completed by executing a set of command sequences. The text file that saves a set of command sequences is called a command script file (using the extension *.cs in the IDE development environment).

(3) Storage area image file: It is used when debugging programs in SDRAM. Accessing illegal storage areas during software debugging will cause exceptions on some processors and target boards. If the exceptions are not handled, the software debugging process will not be able to continue. In order to prevent the above problems and adjust the emulator access speed to the most appropriate level, a file called storage area image file (using the extension *.map in the IDE development environment) is provided to describe the properties of each storage area.

During the debugging process of the program, you can choose to use the storage area image file *.map and command script file *.cs to assist in the debugging of the program.

(4) Startup file: It mainly completes some hardware-related initialization work to prepare for the application. Generally, the first step of the startup code is to set up interrupts and exception vectors; the second step is to complete the register configuration required for system startup; the third step is to set up the watchdog and some peripheral circuits designed by the user; the fourth step is to configure the storage area used by the system to allocate address space; the fifth step is variable initialization; the sixth step is to set the stack pointer for each operating mode of the processor; and the last step is to enter the high-level language entry function (Main function).

2 Interrupt Programming

For interrupt debugging, a dynamic processing method similar to vector interrupt can be used, where the fixed address code corresponding to the interrupt is transferred to a fixed address in RAM, and a function pointer is defined to point to the fixed address. The interrupt handling function can then be dynamically changed at any time by replacing the code at the fixed address in RAM.

The specific method is:

(1) Define the interrupt source function pointer at a relative fixed address in RAM and create an interrupt vector table;

void SetInterrupt (U32 vector, void (*handler)())
{
InterruptHandlers[vector] = handler;
}

(2) In the program, call the interrupt handling function of a specific interrupt source;

For example: SetInterrupt(IIC_INT,IICWriteIsr);

/* Declare the IIC interrupt processing function, where IIC_INT is the IIC interrupt source number, and IICWriteIsr is the IIC write interrupt processing function*/

(3) In the IRQ at 0x18 or the FIQ interrupt entry function at 0x1C, obtain the interrupt source, clear the interrupt pending flag, and enter the user's specific interrupt handler through the defined interrupt source function pointer. [page]

void ISR_IrqHandler(void)
{
IntOffSet = (unsigned int)INTOFFSET;
Clear_PendingBit(IntOffSet>>2) ;
(*InterruptHandlers[IntOffSet>>2])();

//Call a specific interrupt handler
}

By adopting a dynamic interrupt handling method, the interrupt response time and program performance are optimized when there are many interrupt sources. In addition, in terms of debugging, this processing method has the advantage of being easy to track and debug, and the interrupt handling function can be easily changed as needed.

3 Interrupt debugging

Software debugging can be done in SDRAM or FLASH. In SDRAM, reading and writing are convenient and the access speed is fast. Generally, software debugging should be done in RAM, but when the RAM space is smaller than the FLASH program space, the program can only be run and debugged in FLASH, or when the user wants to know the actual running status of the program in FLASH, the program can be debugged in FLASH.

When performing interrupt debugging, it should be noted that the interrupt entry is located at address 0x18 or 0x1c in SDRAM or FLASH. The link script file must correctly locate the code of the entire system at the beginning of 0x0, but the link script file and project configuration corresponding to SDRAM or FLASH should be different.

(1) The program runs in SDRAM

Debugging in SDRAM uses the link script file corresponding to SDRAM. The debugging process requires the following steps: compiling and linking the project; connecting the emulator and the circuit board; downloading the program (using the extension *.elf in the IDE development environment); debugging.

Before downloading the program, you must start the command script file to complete some of the above-mentioned specific operations. The command script file is started automatically when the emulator is connected. The storage area mapping should be the same as when the program is running in SDRAM, ensuring that the code of the entire system is correctly located at the beginning of 0x0. The starting address of the download program is also 0x0. After the download is successful, debugging can be carried out.

(2) The program runs in FLASH

Debug in FLASH, use the link script file corresponding to FLASH. The debugging process requires the following steps: compile and link the project; connect the emulator and the circuit board; convert the program format (convert *.elf to *.bin); solidify the *.bin program; debug.

After connecting to the emulator, there is no need to download the program. The storage area mapping is completed by running the startup file in the project itself, and no command script file is required. During the debugging process in this environment, two hardware breakpoints can be set.

(3) The program is transferred from FLASH to SDRAM for execution

In some applications, when the program running speed is emphasized, it is hoped that the program will run in SDRAM. In this case, the program stored in FLASH needs to be moved to a certain space in SDRAM after the system is powered on, and then run automatically. This so-called Bootloader technology is often used in DSP systems.

The debugging process is divided into two steps:

(a) First debug the user program in SDRAM, and then fix the *.bin file to a non-0 sector address space of FLASH;

(b) Debug the Bootloader transfer program written by yourself and fix the Bootloader.bin file to the 0 sector address space of FLASH. After the system is powered on, the transfer program will transfer the program stored in a non-0 sector address space of FLASH in (a) to the same space location in SDRAM debugging, thereby achieving the purpose of running the program in SDRAM.

Also note that because the user's actual program interrupt entry must be located at address 0x18 or 0x1c of FLASH, the Bootloader transfer program should also have the function of jumping to the interrupt entry, that is, to transfer the PC pointer to the interrupt program entry table in the SDRAM space, which is the location where the entire user program is transferred to SDRAM.

Such as: LDR PC, =HandleIRQ

// HandleIRQ is located in the SDRAM space interrupt program entry table

Keywords:Embedded Reference address:Embedded skills: Introduction to three interrupt debugging methods of ARM

Previous article:How to automatically run a specific program after ARM Linux boots up
Next article:Wireless Communication System of Multifunctional Monitor

Recommended ReadingLatest update time:2024-11-16 22:44

ARM coprocessor access instructions (Linux learning records)
What is a coprocessor? Coprocessors are used to perform specific processing tasks, such as math coprocessors that can control digital processing to reduce the burden on the processor. ARM can support up to 16 coprocessors, of which CP15 is the most important one. What is the function of CP15? The system control
[Microcontroller]
9. Mixed programming of ARM assembly and C
9.1 Mixed programming of ARM assembly and C 9.1.1 Embedded assembly __asm __asm("command") For example, turn off/on the general interrupt switch CPSR __asm ​​//Use variable names in C instead of registers {     MOV was,x     ADD y,var,x/y } Register names in inline assembly language are treated by the compiler as va
[Microcontroller]
9. Mixed programming of ARM assembly and C
arm stack operation
The organizational structure of the arm stack is in the form of full stack descending. A full stack means that sp is to stay at the last element pushed into the stack. Descending means that the growth direction of the stack is from high address to low address.   ARM generally uses two commands, LDMFD (pop) and STMFD (
[Microcontroller]
Design of remote wireless video monitoring terminal based on ARM
At present, in the field of video surveillance systems, wired video surveillance systems are more common. However, they have a short effective distance and high cost, and are only suitable for small-scale regional monitoring. For some special monitoring occasions, such as oil field production sites, remote envir
[Microcontroller]
Design of remote wireless video monitoring terminal based on ARM
ARM IMPORT Image$$RO$$Limit meaning
ARM IMPORT Image$$RO$$Limit meaning IMPORT |Image$$RO$$Base| ; Base of ROM code IMPORT |Image$$RO$$Limit| ; End of ROM code (=start of ROM data) IMPORT |Image$$RW$$Base| ; Base of RAM to initialise IMPORT |Image$$ZI$$Base| ; Base and limit of area IMPORT |Image$$ZI$$Limit| ; to zero initialise IMPORT MMU_SetAsyncBusMo
[Microcontroller]
ARM programmer's Model learning
ARM supports three data types: byte, half-word, and word. (V4 and above, the current low-end mobile phone chips are basically V5 version ARM9) There are 2^32 values ​​that can be expressed. For signed data values, there are values ​​on the negative half axis, and for unsigned data, there are values ​​only on the r
[Microcontroller]
ARM programmer's Model learning
ARM assembly instruction set 3
Common ARM instructions 1: data processing instructions      •Data transfer instructions mov mvn       mov r1, r0 @Data transfer between two registers       mov r1, #0xff @Assign the immediate value to the register mov and mvn are used in the same way, the difference is that mov is passed intact, while mvn is passed a
[Microcontroller]
Remote Video Monitoring System Based on ARM and CDMA
0 Introduction CDMA (Code Division Multiple Access) network has the characteristics of wide coverage, high efficiency and low cost. The data transmission rate of CDMA network can reach 200kb/s. The embedded remote video system developed here is a data transmission system built by making full use of the characte
[Microcontroller]
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号