Classic Q&A on Embedded ARM Development Boards

Classic Q&A on Embedded ARM Development Boards

Classic Q&A on Embedded ARM Development Boards

The development board (demoboard) is a circuit board used for embedded system development, including a series of hardware components such as a central processing unit, memory, input devices, output devices, data paths/buses, and external resource interfaces. Development boards are generally customized by embedded system developers based on development needs or can be designed by users themselves. Development boards are for beginners to understand and learn about the hardware and software of the system, and some development boards also provide basic integrated development environments, software source code, hardware schematics, etc. Common development boards include 51, ARM, FPGA, DSP development boards.

Here we will first talk about ARM development boards:

Classic Q&A on Embedded ARM Development Boards

ARM development boards are embedded development boards that use the core chip from the British ARM (Advanced RISC Machines) company as the CPU and add other peripheral functions to evaluate the functionality of the core chip and develop products for various technology companies.

ARM development boards can be classified into ARM7, ARM9, ARM11, Cortex-M series, Cortex-R series, and Cortex-A series based on the ARM core. Among them, the Cortex-M3 series can be further divided into Cortex-M0, Cortex-M0+, Cortex-M3, and Cortex-M4; the Cortex-R series is divided into Cortex-R4, Cortex-R5, and Cortex-R7; the Cortex-A series includes Cortex-A5, Cortex-A7, Cortex-A8, Cortex-A9, Cortex-A15, Cortex-A50, etc. Thus, there are corresponding core development boards such as Cortex-M0 development board, Cortex-A5 development board, Cortex-A8 development board, Cortex-A9 development board, Cortex-R4 development board, and so on. Since ARM only provides the ARM core externally, major manufacturers develop and produce their own chips based on the paid authorization to use the ARM core, forming a large family of embedded ARM CPUs. Manufacturers providing these core chips include Freescale/NXP, TI, Atmel/Microchip, ST, Samsung, etc..

Well-known companies that produce ARM series development boards include Yujian Hengtian, Runer Information (formerly Guangzhou Huatianzheng Technology), Feiling, Youshan, Tianqian, Tianmo, Youlong, Bochuang, Yangchuang, Seeed Studio, Jingyida Sheng Technology, Mi Er Technology, Chuanglong, etc.

Classic Q&A on Embedded ARM Development Boards

Question 1:

Q: What mode is the processor in when executing the instruction mov r0, LR at the beginning of CPU stack initialization?

A: Reset mode, i.e., supervisor mode.

Question 2:

Q: Could you explain: What is the 8-bit immediate number in MOV? How did 0xF0000001 come about?

A: It is a circular right shift, which is a number between 0-255 shifted left or right by even bits. This means that the number is divided by 4 until it is an integer within the range of 0-255, which indicates that it is valid!

Question 3:

Q: In Section 2.2.1 of “Fundamentals and Practices of ARM Microcontrollers”, there is a description about the second operand:

#inmed_8r constant expression. This constant must correspond to an 8-bit bitmap, which means it is derived from an 8-bit constant shifted by even bits.

Valid constants: 0x3FC, 0, 0xF0000000, 200, 0xF0000001.

Invalid constants: 0x1FE, 511, 0xFFFF, 0x1010, 0xF0000010.

Examples of constant expression applications:

LDR R0,[R1],#-4; Read the content of the memory unit at the address of R1, and R1 = R1-4. Regarding this segment, my question is:

1. How to understand that the constant is derived from an 8-bit constant shifted by even bits? 2. The constant must correspond to an 8-bit bitmap, since it is an 8-bit bitmap, how is 0x3FC a valid constant exceeding 255? 3. In the examples given, how are valid and invalid constants distinguished, such as 0x3FC being valid while 0x1FE is invalid; 0xF0000000 and 0xF0000001 are valid, while 0xF0000010 becomes invalid? 4. For the assembly statement LDR R0,[R1],#-4, does it first subtract 4 from R1 and store the result in R1, then read the value pointed to by R1 into R0, or does it first read the value of R1 into R0, and then subtract 4 from R1?

A: Hint: Any constant can be represented as a base * 2 to the power of n.

1. In ARM architecture, only 8 bits are used to represent the base, so the base must be an 8-bit bitmap.

2. The 8-bit bitmap can be circularly shifted to obtain constants, but it does not necessarily have to be 8 bits.

3. 0xF0000010 has a base of 9 bits and cannot be represented.

4. LDR R0, [R1], #-4 is post-indexing, which means it reads first, then subtracts.

For more details, please refer to the ARM architecture documentation regarding related addressing modes.

Question 4:

Q: During the process of program porting, what code segment is in what mode? This is indeed a perplexing problem. Is there a flag or method to identify “what mode the code segment is in”?

A: Read CPSR, it can be read at any time.

Question 5:

Q: Why is it that when protecting the scene, R0-R3 and R12 are always protected, but R4-R11 are not?

A: Please refer to the document “ARM-Thumb Procedure Call Standard”.

Question 6:

Q: Why does the error “mov R1,#0x00003DD0 out of the range of operation” occur? I just want IODIR=0x00003dd0, and the assembly is LDR R0,=IODIR MOV R1,#0x00003dd0 STR R1,[R0]

The compiler indicates that it is out of the operating range.

A: Use ldr, the operand for mov is an 8-bit bitmap number.

Question 7:

Q: “There are 37 user-visible registers inside the ARM7TDMI(-S) processor:” What does “user-visible” mean? Are these 37 registers different physical registers, for example, R8 and R8_fiq should be two different physical registers, right?

A: User-visible means that users can manipulate them through programs. R8 and R8_fiq are two different registers.

Question 8:

Q: What are the limitations of USR mode, SVC mode, and IRQ mode?

A: The restrictions on peripheral operations are related to chip design. The USR mode cannot set the CPSR register.

There is no SPSR register in user mode, and the code can be either ARM or Thumb.

Question 9:

Q: What does “the working mode is determined during stack initialization” mean, and how is the working mode determined?

A: Set the CPSR register.

Question 10:

Q: What does “literal pool” mean in ARM assembly programming?

A: It can be understood as an array of constants. The literal pool contains constants, which can be normal constants or addresses.

Question 11:

Q: Why is it that in the interrupt vector table, we do not directly use LDR PC, “exception address” but instead use a label and then use DCD to define that label later?

A: Because the LDR instruction can only jump within a range of 4kB from the current PC, while the B instruction can jump within a range of 32MB. Thus, by using LDR PC, “xxxx” and defining a word containing the final exception service program address with “xxxx” DCD nearby, we can achieve a 4GB full-range jump.

Question 12:

Q: What is the difference between ARM7TDMI-S and ARM7TDMI?

A: ARM7TDMI-S is the synthesizable version (soft core) of ARM7TDMI.

For application engineers, unless the chip manufacturer has modified the ARM7TDMI-S, there is not much difference between ARM7TDMI-S and ARM7TDMI, and its programming model is consistent with ARM7TDMI.

Question 13:

Q: Doubts about the DCD pseudo-instruction.

“StackUsr DCD UsrStackSpace + (USR_STACK_LENGTH – 1) * 4” What does this statement mean? What does the program label or numerical expression after DCD represent?

A: It initializes the highest address of the decrementing stack. Please refer to Section 2.3.2 of “Fundamentals and Practices of ARM Microcontrollers”.

Question 14:

Q: 00254: Unimplemented RDI message what error prompt is this? My settings and connections are normal; is the chip burned?

A: It is a JTAG issue. You can try using ISP to see if it works. If it can use ISP, it indicates that LPC2104 is not damaged and can still run programs normally.

Question 15:

Q: I encountered this prompt in AXD while debugging my program:

RDI Warning 00159: could not open specified device port.

I set it up according to the steps in the accompanying tutorial.

A: Please install the driver according to the instructions in the CD\easyarm_drive\readme.txt.

Question 16:

Q: I frequently encounter the following information when running the experimental program! The program cannot be downloaded to the target board.

Warning! Interrupt vectors data is not correct!

Program you downloaded cannot run freely!

A: 1. The emulator configuration must be correct, i.e., select “Erase Flash when need” in the “FLASH” item of the “EasyARM Configuration” settings window; 2. The sum of the vector table must be 0; 3. You can first debug a program in RAM (run), then STOP, and then use File->Load Image… to load the debugging file to be downloaded to FLASH.

Question 17:

Q: Is it possible to perform software debugging of programs based on UCOS-II in ADS?

A: ADS software debugging can only debug the ARM core, not peripherals. However, after canceling the PLL lock detection, task switching can be debugged, ultimately reaching the idle task. Software simulation is the best tool during the initial porting.

Question 18:

Q: What is the purpose of ARMulate software? Isn’t 2104 simulated using EasyJTAG.dll?

A: Software simulation can only simulate the ARM core.

Question 19:

Q: Regarding the LPC2106.INC file. I cannot reference the lpc2106.inc file in the project; I can only reference the lpc2106.h file. What is the reason? And when my main program is written in assembly, I cannot reference lpc2106.h, and if I use lpc2106.inc, it cannot be added to the project. How should the assembler be set?

A: You don’t need to add 2106.inc; as long as the file is in your project folder, you can directly add “include 2106.inc” at the beginning of the assembly program.

Note: This file is an assembly file defining the header file, defining internal registers.

Question 20:

Q: What does the entry point mean? When I use LPC2106 to port UCOS-II, I get the prompt “Image does not have an entry point” every time I MAKE, but I have copied the vectors.s from the CD, and I carefully checked it and declared ENTRY. What is going on?

A: You need to set the entry point in ADS.

Question 21:

Q: How to define uninitialized variables? A: Let the compiler not know that there is this memory address.

A: You can reserve a portion of RAM intentionally using a scatter-loading file for RAM allocation, to store things you do not need to initialize. Alternatively, you can not call the startup code provided by the compiler, but this may complicate programming.

Question 22:

Q: I directly downloaded the Ext1_test program that came with the EasyArm board through the JTAG port to the ARM, and encountered a warning about the interrupt vector:

Interrupt vector is not correct; ARM is not running freely.

Indeed, after resetting, the chip cannot run. However, when I download it via the serial port, the chip can work normally, and the interrupt works.

Moreover, when I use JTAG simulation, the chip can work normally, and the interrupt works, but it does not work only when downloading through the JTAG port.

I don’t know the reason?

A: In the emulator configuration, you need to set the option to allow erasing FLASH. You can also try this:

1. First, open a project and debug it in RAM; 2. Stop the program; 3. Use File->Load Image… to reload the Ext1_test generated *.axf file.

Question 24:

Q: I encountered the following prompt during simulation:

Error, Flash is protected by user configuration!

How to write to flash?

A: Refer to Appendix 1 of “Fundamentals and Practices of ARM Microcontrollers”.

Question 25:

Q: I thought of two questions during the porting experiment:

1. What are the differences between Debug, Release, and DebugR? Why do we need to use Release during the 2104 porting experiment? 2. Why do we set RW Base to 0x40000040 in Release? I set it to 0x40003000; why can’t it work?

A: They are all just one issue, which is the use of memory space, because running an OS requires a relatively large memory space, so some space needs to be freed up.

Question 26:

Q: Does ARM chips without MMU support the use of malloc() function for dynamic memory allocation?

A: Whether malloc() function is supported or not is not much related to the chip, but mainly related to the compiler.

Q: Again, if there is no operating system support?

A: It is still supported.

Question 27:

Q: In the I2C experimental program, I want to view the value of the data buffer DataBuf, how can I view it?

A: Watch window or hover the mouse over the variable name to view.

Q: I am querying the value written to the DataBuf buffer, but the mouse does not show its value, and even adding it to the watch results in “name not found”.

A: The variable has been optimized; during debugging, you can define the variable as a global variable to view.

Question 28:

Q: The simulation software cannot connect to the 2104 development board DBE Warning 00041:

!An unspecified Debug Toolbox call failed. The power and development board are connected properly, and the error is the same as if the development board is not connected. The driver has also been installed, and the software takes a long time to respond when I press the OK button; please help.

A: 1. Check if the parallel port is normal; 2. Try it on another operating system (like 98) or another desktop PC.

Question 29:

Q: How to generate a 32-bit hex file? I set it to Intel 32bit HEX in Release Setting->ARM from ELF->Output Format, but it seems that no hex file is generated.

A: Try this method:

Target->Target Setting->Post Link, select “ARM from ELF” and it should work without issues.

Question 30:

Q: What do r0 base and rw base mean in settings?

A: ro: read-only, rw: read and write.

Question 31:

Q: What do code, R0 data, RW data, ZI data, and debug represent in the first line of the information after compilation?

A: R0 is the read-only segment, i.e., program code space; RW is the read/write segment, i.e., data variable space; ZI is the zero-initialized variable segment, i.e., the space for data variables that need to be initialized to zero.

Question 32:

Q: How to view the execution status of tasks in ADS, such as the stack?

A: Multi-task environment stack, memory, and other information require the support of debugging software to implement.

There is a statistical function module under ucos that can indirectly achieve part of the functionality.

Question 33:

Q: When writing data to flash, the prompt “exceeds flash limitation” appears. Please advise!

A: The address to be written to flash exceeds the range. If it is not a problem with the code being too large, check if the scf file is correct.

Question 34:

Q: How to achieve absolute address positioning of arrays in chips like LPC2214, e.g., the _at_ usage of 51?

A: *((char*)0x40000300) is similar to access.

Q: Thank you, but this way does not require defining array variables, and access is also inconvenient. Is there a better way?

A: You can use scatter-loading.

Question 35:

Q: What does the ADS compilation error “L6221E: Execution region ER_RO overlays with Execution region ER_ZI” mean? How to solve it?

A: Please try using the project template on our website; the most likely reason is that your RELEASE or DEBUG options are not set correctly. Following the settings in “Fundamentals and Practices of ARM Microcontrollers” should not have this problem.

Question 36:

Q: Please advise: After writing the program to flash, if I debug it, the program does not respond after writing it in the JTAG way.

I have read many previous posts, and it is said that the memmap register should be set to 1. I used a very simple example of controlling an LED, and after modifying the parameters, I wrote it to flash. In this program, I cannot find any part about the memmap register operation in the vectors. What is going on, and what should I do?

A: Appendix of “Fundamentals and Practices of ARM Microcontrollers” lists several reasons why programs written to FLASH cannot run.

Memmap operations can be added in the TargetResetInit() function in target.c.

Question 37:

Q: The HEX file. The EASY2100 paired with “Fundamentals and Practices of ARM Microcontrollers” states: Compile the project into a HEX file, but I don’t know how to do it. What should I do?

A: Set Post-linker in Target->target settings to Linker->from ELF.

Q: Again, I am using the example from the CD, and the project in the project folder is DebugInARM.DebugInFlash.

RelInFlash. It is not DebugRel as shown in “Fundamentals and Practices of ARM Microcontrollers”. I have set it according to “Fundamentals and Practices of ARM Microcontrollers”, but I can download it using ISP, and it prompts that the HEX file cannot be found.

A: The examples on the CD are created using dedicated project templates, which have their parameters set, and are different from the default template.

Question 38:

Q: How to download to Flash through the JTAG interface on the EasyARM2100 development board? When using the EasyARM2100 development board, the JTAG interface cannot perform Flash debugging (DebugInFlash), but it can debug in RAM (DebugInRAM), and programming can be written to Flash via ISP.

When debugging through the JTAG interface, the following prompt always appears:

Flash Sector 0 write failed!

Warning: Interrupt vectors data is not correct!

Program you downloaded cannot run freely!

What could be the reason? How should I proceed?

A: There is an option in the emulator settings that allows erasing FLASH; select it.

Question 39:

Q: I found that the program works fine in RAM debugging (RO=0X40000000), but when downloaded to FLASH (RO=0X00000000) via JTAG, the following message appears:

The session file ‘c:\Documents and Settings\jan\default-1-2-0-0.ses’ could not be loaded.

A: This is an issue with ADS itself; please do not run AXD through the IDE, but rather run it through the Start menu, and then load the debugging file to debug.

Question 40:

Q: I have a few questions to ask everyone.

What is the best high-level language to compile ARM source programs for the debugging host? What debugging software (like AXD) is used for JTAG debugging? Is AXD similar to some software? Where can I download the AXD debugging software? How to perform JTAG debugging with AXD? How to send the program to the target machine using the JTAG emulator? What software is used for debugging microcontrollers, and what are their functions?

A: You can use ADS1.2; Keil C also supports it. AXD is a component of ADS.

You can download the EasyARM2100 development kit quick start guide from our company website.

Question 41:

Q: An error occurred during debugging with EasyARM2100AXD. The fault phenomenon:

After setting up ADS1.2 according to the method on the CD, I opened the project file examples\gpio\c\LedDisp (copied from the CD to the hard drive, and removed the read-only attribute).

After compiling successfully, I pressed the Debug button to run the debug, entered AXD, and pressed the Go button, but EasyARM did not respond. Then I pressed the Stop button.

AXD pops up two confirmation dialog boxes:

“No disassembly could be read at the requested address”.

If I enter AXD and directly press the Step button, the same two confirmation boxes also pop up.

The software is from the CD and has not been modified. There are several examples on the CD that exhibit this situation.

AXD’s settings are configured according to the instructions on the CD.

The JP8 on EasyARM is disconnected. ADS has been reinstalled after this issue appeared, but the fault remains.

Before this issue occurred, I could debug, but it felt relatively slow during single-stepping, taking about 1-2 seconds for each step.

A: The reason has been found; the chip is encrypted and cannot write a new program. After clearing it using FLASH ISP, the issue was resolved.

Once encrypted, JTAG cannot fully control the chip, as it may be decrypted.

Question 44:

Q: Please, my 2104 board, when using EasyJTAG simulation, there are no files in AXD, and the prompt appears “Error, Flash is protected by user configuration!” What is the problem? What type of file should be opened in AXD? Thank you!

A: In the emulator configuration window, set the emulator to allow erasing FLASH.

AXD->Options->configure target->configure->eraseā€¦

Question 45:

Q: Regarding the special usage of jump instructions in ARM assembly language. There are two jump instructions:

beq labelf beq labelb where label is a label of a certain segment of the program; beq labelf indicates a forward jump to the nearest label label from the current instruction, while beq labelb indicates a backward jump to the nearest label label from the current instruction.

Is there any definition of such usage in ARM assembly?

A: No.

Question 46:

Q: I want to understand in detail the meaning of the code in stack.s, heap.s, and startup.s in the ADS development tools. Can experts recommend a book or explain it?

A: Section 3.1.3 of the user guide for the development kit has an explanation.

stack.s defines the starting address of the system mode stack.

heap.s is the heap for initializing library functions, written according to ADS compiler requirements.

startup.s contains the vector table and initialization code, written according to the CPU.

Question 47:

Q: I do not know whether the selected C file is compiled using ARM or THUMB; can experts provide guidance!

A: Refer to Sections 7.1, 7.2, and 7.3 of “Fundamentals and Practices of ARM Microcontrollers”.

Question 48:

Q: I created a new project without using a template, and during the compilation of TEST.C, it prompted that OS_EVENT was not declared. However, I checked the code, and TEST.C includes CONFIG_EX.H, and config_ex.h includes include_ex.h, and these two header files include ucos_ii.h, where OS_EVENT is declared. I do not know why this error occurs. Can you provide a reasonable directory structure?

A: Please refer to the directory structure on our CD. It is best to use our project template.

Question 49:

Q: Please, I am currently developing a product for the 2114 and have encountered the following issue; I would like to ask for your advice! Issue:

Our developed product needs to sample at a fixed cycle. Therefore, we use timer0 for clock triggering, utilizing the interrupt program to sample every 10 milliseconds and display the waveform. This works well. However, when assigning values to several global variables in the interrupt program, the global variables cannot be used after exiting the interrupt! I am very troubled! Please advise!

14 The framework is as follows:

uint8 a; // Global variable void __irq funtimer0(){…

a=0; // Assign value to the global variable inside the interrupt function…

}

void fun1(){ uint8 i; i=0;…….

i=a; // Error location, during debugging when running to this location, moving the mouse over variable a shows that the value is 0, but it cannot be assigned to i; the value of i does not change with this command.

…… }

A: Declare global variables as volatile.

Question 50:

Q: In AXD, when opening Debuger Internals, why are there no registers like PINSEL2, ADDR, ADCR in the Variable Name?

A: Some internal peripheral registers cannot be read out; refer to page 33 of “Fundamentals and Practices of ARM Microcontrollers” for explanations and methods (write the corresponding register address in the Memory window).

Question 51:

Q: Can I directly debug the program without connecting to the EasyArm board? I mean, if I want to debug the software part directly, can I debug in ADS or AXD?

A: It has nothing to do with the board; you can directly select ARMulate, just make sure to comment out the statement that waits for the PLL configuration to complete!

Question 52:

Q: In AXD, the message “RDI Warning 00159: Could not open specified device port” appears. Can someone tell me what this problem is? I have been struggling with it, and I have set everything according to the diagrams in Chapter 4 of “Fundamentals and Practices of ARM Microcontrollers” but still cannot simulate.

A: Please first install the driver according to the instructions in the CD\easyarm_drive\readme.txt.

Question 53:

Q: 1. In Section 2.6.3 of “Fundamentals and Practices of ARM Microcontrollers”, it is mentioned that “floating-point registers (F0-F7…)”; does 2104 have these registers? 2. If EasyArm does not support floating-point operations, but my program requires floating-point operations, can it be implemented?

A: No.

Question 54:

Q: Why are the example programs of EASYARM2104 all calling C programs, but there are no assembly ones?

A: Follow these steps:

1. Delete all original files in the project management window; 2. Add assembly files *.S in the project management window; 3. Compile, link, and debug.

Question 55:

Q: In AXD debugging software, when I single-step to a certain point, I want to restart my software from the reset point. In the AXD software, the EXECUTE column has functions like step, continue, run to cursor, etc., but there is no reset function. If I want to achieve this function, how should I operate?

A: I have not found a reset function; currently, the only way to implement it is by reloading the operation.

Question 56:

Q: In AXD debugging, when connecting to LPC2106 through the JTAG interface, the following information appears:

TKSimulator for ADS, V1.2, 2003/08 Software Supplied by: ZLG MCU ARM7TDMI-S, Little Endian. When loading a file | load image…, two situations may occur:

1. Normal, can debug completely; 2. A problem occurs, as follows:

RDI Warning 00254: Unimplemented RDI message. Please tell me where the error is and how to resolve it. Thank you!

A: It may be caused by poor contact with the power supply or other connectors.

Question 57:

Q: A few questions to ask:

1. Can the __swi keyword in the lower-level interface be used in SDT? 2. Why was the macro for enabling and disabling interrupts removed from the clock tick service subroutine in the errata document? 3. Should the priority of the clock tick interrupt be set to the highest?

A: 1. I don’t know, please refer to the documentation that comes with the software.

2. Because the interrupt service routine must disable interrupts.

3. It is not necessary.

Question 58:

Q: What do the square brackets mean in ARM assembly? For example, in the following example, what is the function of the square brackets? [PLLONSTART ldr r0,=PLLCON ldr r1,=((0xe8<<12)+(0x4<<4)+0x2) str r1,[r0]

A: Equivalent to: IF PLLONSTART ldr r0,=PLLCON ldr r1,=((0xe8<<12)+(0x4<<4)+0x2) str r1,[r0]

Question 59:

Q: In Init.s, there is a segment like this:

ResetBL InitStack; Initialize stack BL TargetResetInit; Basic initialization of the target board B __main; Jump to the C language entry point. Who knows the specific content of the __main() function? If I do not need to call library functions, can I change it to B main?

A: The __main() function is in the assembly code; its components are related to some linking options.

You can, but global variables cannot be initialized.

Question 60:

Q: I embedded the following statement in C: __asm{MRS R4,CPSR; STMFD SP!,{R4}; ORR R4,R4,0x80; MSR CPSR_cxsf,R4}

It raises a new error “illegal write to sp”. Does the moderator or any experts have a solution?

A: Embedded assembly cannot use SP.

Question 61:

Q: What does the ADS compilation error mean L6221E: Execution region ER_RO overlays with Execution region ER_ZI?

A: The memory allocation of the program segment may have issues, RO (read-only), ZI (zero-initialized).

Question 70:

Q: Is there a runtime timer in AXD like the one in Keil?

A: Yes, but it is not a timer but rather an execution cycle, which can be converted to time. In Debugger Internals, you can refer to the help documentation for specifics.

Question 72:

Q: I initially did not include heap allocation and __user_initial_stackheap functions in init.s, resulting in the program jumping into a SWI infinite loop. After adding them, it worked. Alternatively, if they are not added, changing B __main to B main can also work. Why is that? Furthermore, even if the target board enters an infinite loop, it can run normally in software simulation. Why is that?

A: The heap location has not been allocated to valid RAM.

Question 73:

Q: In ARM assembly language, there are requirements for immediate numbers; I remember there were no such restrictions before. Now I am more cautious when using immediate numbers, unlike in 51 where they could be used freely. Can someone clarify this for us?

A: You can use the method of “illegal data can be loaded into the register”.

First, define a constant in memory, then load it with ldr, and the compiler handles it this way. You can see the difference in disassembly between: int z=0x101; int z=0Xff;

Question 75:

Q: Since the Image entry Point filled in the options is the debug entry address, it will not overwrite the ENTRY declaration in the code during actual program execution, right? It is only for debugging convenience.

A: The Image entry Point takes precedence. In fact, the ENTRY in the code is to ensure that the code is not optimized away.

Question 76:

Q: I want to use standard C library functions, such as memset, which is defined in string.h, but I directly include #include, but there are no compilation errors, yet runtime errors occur. How should I set it up?

A: Please use the latest project template.

Question 77:

Q: Is a software interrupt necessarily triggered by the SWI instruction?

A: You can directly use the function name defined as a soft interrupt. For example:

19 __SWI(0x12) void myswi(void); // Declare function __asm // Calling method 1 {swi 0x12}

myswi(); // Calling method 2

Question 78:

Q: The program listing in “Fundamentals and Practices of ARM Microcontrollers” is called at _user_initial_stackheap LDR r0,=bottom_of_heap MOV pc,lr; /* Allocate heap space */ AREA Myheap, DATA, NOINIT, ALIGN=2 bottom_of_heap SPACE 256; The heap space for library functions. My questions are:

1. Where is this function called? 2. After assigning a value to r0, is it finished? What role does r0 play?

A: This is the function for allocating heap and stack, called by the initialization code provided by ADS; for specifics, refer to the relevant sections of “Fundamentals and Practices of ARM Microcontrollers”.

Question 79:

Q: Is the startup code for 2104 applicable to 2124? The easyarm2104 project template downloaded from the website states that it is an arm executable image for lpc21**, which means it is also applicable to 2124. If not, what needs to be modified?

A: You can download the 2100 project template.

Question 80:

Q: I am using the IAP function of ARM to write data already burned into flash into RAM, and I wrote:

uint32 *q,data; q = 0x00006000; data = *q; This is the starting address of the flash to be read, but the second statement compiles with an error. I think the C compiler does not allow direct assignment to the pointer. I solved this simple problem with assembly, but how can I solve it using C?

A: q = (uint32 *)0x00006000;

Question 81:

Q: What does the function srand((INT32U)TargetInit) do at the beginning of the TargetInit() function?

A: ex1 uses it to generate a random seed.

Question 82:

Q: In vectors.s, does the “DCD 0xb9205f80” need to be modified in practical applications?

A: No need to change, unless the instruction code in the vector table is modified.

Question 83:

Q: Why is the queue data queue drawn as a circular shape in “Fundamentals and Practices of ARM Microcontrollers”?

A: Because the head and tail pointers point to one address; logically, the queue is circular.

Question 84:

Q: Has anyone successfully defined a data structure in program space? I have tried various methods; is there any compilation switch?

A: Use const to modify, and define the variable with an initialization value; it must be a global variable.

Question 85:

Q: In the example, how to make the defined string array not occupy RAM space, like the CODE keyword in Keil?

A: const unsigned char string[]

Question 86:

Q: In the TIME_test routine, when writing TIMEOUT, it prompts:

Warning! Interrupt vectors data is not correct!

Program you downloaded cannot run freely!

I do not know how to modify the settings; could someone remind me?

A: The checksum of the interrupt vector table is not 0; use AXD to check the data at address 0 (32-bit mode), and make adjustments. Be careful to remove any part above 32 bits.

Question 87:

Q: Please advise: I encountered the following error prompt during the TIMEOUT experiment (2104 board): Make passed, but during debugging, I received the following prompt:

Warning! Interrupt vectors data is not correct!

Program you downloaded cannot run freely!

Link settings: ARM Link r0 base: 0x00000000 rw base: 0x40003000 image entry point: 0x00000000; nothing else changed!!

However, I can download and run it completely using ISP! This could be a settings issue, but I cannot find it!

A: Please refer to Appendix 1 of “Fundamentals and Practices of ARM Microcontrollers”; the ISP software may have handled it, while JTAG did not have special handling.

Question 88:

Q: What does *(volatile unsigned int *) mean? For example, *(volatile unsigned int *)addr; what does it specifically mean?

A: To break it down, (volatile unsigned int *) is defining a pointer to a volatile unsigned integer, and the * before it means to take its content.

Question 89:

Q: How to understand #define VICIRQStatus (*((volatile unsigned long *) 0xFFFFF000))?

A: It is a macro definition; refer to books on C language.

(volatile unsigned long *) 0xFFFFF000 forcibly converts 0xFFFFF000 to a pointer, then *(pointer) can be used to access that address.

Question 90:

Q: In the settings of the exception handling vector table, why do we not directly write the entry address of the exception vector into PC? Why do we have to use DCD and these pseudo-instructions? What is the use?

A: To ensure that the checksum is zero at all times; otherwise, every time a program is modified, it needs to be recalculated.

Question 92:

Q: Please advise: How to modify the startup code of ADS, from __main to main? In theory, there should be a file to modify this small file.

A: __main is the ADS runtime library; it is best not to modify it. If you do not use the library, do not use the main() function; use another name and directly jump to it.

For details, see P328 of “ARM Architecture and Programming”.

Question 93:

Q: I encountered a dialog box during JTAG simulation that prompts:

Warning! Interrupt vectors data is not correct!

Program you downloaded cannot run freely!

A: Refer to Appendix 1 of “Fundamentals and Practices of ARM Microcontrollers” for the first question’s second part; choose the source code’s startup code folder’s vectors.s and set it according to the diagram in “Fundamentals and Practices of ARM Microcontrollers” (Figure 7.11).

Question 94:

Q: What does the allocation of the stack in the initialization code mean? MSR CPSR_c, #0xd3; Enter a specific processor mode LDR SP, StackSvc; Assign the stack pointer for the current processor mode. This is just a value; the following DCD statement assigns SvcStackSpace SPACE SVC_STACK_LENGTH * 4 to open up memory of size SVC_STACK_LENGTH * 4, and SvcStackSpace is the label for this memory. This should be easy to understand.

StackSvc DCD SvcStackSpace + (SVC_STACK_LENGTH – 1) * 4; This statement adds the size of the stack to this address.

A: It calculates the stack pointer; I think this stack grows downwards, so SP is assigned the highest address of the stack.

Question 95:

Q: What does the statement in the startup code mean? 24__user_initial_stackheap LDR r0,=bottom_of_heap MOV pc,lr; /* Allocate heap space */ AREA Myheap, DATA, NOINIT, ALIGN=2 bottom_of_heap SPACE 256; The heap space for library functions. My questions are:

1. Where is this function called? 2. After assigning a value to r0, is it finished? What role does r0 play?

A: This is the function for allocating heap and stack, called by the initialization code provided by ADS; for specifics, refer to the relevant sections of “Fundamentals and Practices of ARM Microcontrollers”.

Question 96:

Q: Is the startup code for 2104 applicable to 2124? The easyarm2104 project template downloaded from the website states that it is an arm executable image for lpc21**, which means it is also applicable to 2124. If not, what needs to be modified?

A: You can download the 2100 project template.

Question 97:

Q: I am using the IAP function of ARM to write data already burned into flash into RAM, and I wrote:

uint32 *q,data;q = 0x00006000;data = *q; This is the starting address of the flash to be read, but the second statement compiles with an error. I think the C compiler does not allow direct assignment to the pointer. I solved this simple problem with assembly, but how can I solve it using C?

A: q = (uint32 *)0x00006000;

Question 98:

Q: Ask a basic question about assembly.

Example: ANDS R1,R1,#0x0400 BEQ WAITOK. How does ANDS affect the flag bits, and which two operands does BEQ judge to execute?

A: R1&0x0400 => R1; if the result is 0 (i.e., R1 is 0), then the flag bit Z=1.

When Z=1, BEQ WAITOK executes effectively.

Question 99:

Q: Please advise: How to determine a fixed physical address for a variable in ADS, similar to the XDATA xxx _AT_ 0x4456 functionality in Keil?

A: Use scatter-loading mechanism; mem_c.scf, etc., are examples.

Question 100:

Q: Where can I find information on C language programming for ARM?

A: In fact, most embedded systems C language programming is similar; you can find a book on embedded C language.

Question 101:

Q: Is it true that after system reset, the first execution is the interrupt vector of the Boot Block, and then the program in the boot block decides whether to execute the user program or ISP program?

Then how are the interrupt vector tables of the boot block and user program arranged in flash? In “Fundamentals and Practices of ARM Microcontrollers”, I saw that the lowest 64 bytes of the boot sector after reset appear in the 0x00000000 area. Shouldn’t the user interrupt vector table be in another area? Generally, it is at 0x00000000 in products, and in the development board, after rebooting, it is actually at the interrupt vector address of the boot block, right?

A: Refer to Section 3.3.6. Generally, it is at the physical address 0.

Question 102:

Q: In the program listing of “Fundamentals and Practices of ARM Microcontrollers”, it states:

uint32 i; i = VICIRQStatus; i = IOSET; why must VICIRQStatus be read first before reading IOSET?

A: Reading VICIRQStatus is just for observing its current value, and has no other purpose.

Question 103:

Q: In what situations is the processor in user mode? Thank you!

A: You need to set the CPSR register.

User programs generally run in user mode/system mode.

Question 104:

Q: What does the standalone B instruction in EINT1_LED.S mean? Thank you!

A: It is “B .”, which jumps to the current address, i.e., an infinite loop, equivalent to the following code:

HALT B HALT

Question 105:

Q: What exactly is in the template?

A: Startup code, relevant compilation and linking settings.

The startup code is used to initialize the system, such as Startup.s, target.c, stack.s, etc.

Question 106:

Q: I tried using the project template today. I created a project using ARM Executable Image for lpc21xx and noticed that the startup file is different from the original; I used an example from “Fundamentals and Practices of ARM Microcontrollers” for testing, which uses the time0 timer interrupt to light up the LED. The example’s TargetInit() and int main(void); modified the user stack and bottom_of_heap lengths, and the program can run but cannot generate interrupts; the time0 and VIC initialization are correct. What could be the reason? The project folder created using the project template in src has several files, including mem_a.scf, mem_b.scf, mem_c.scf; how can I import them into the project? Thank you!

A: The default startup.s is configured to disable interrupts!

Classic Q&A on Embedded ARM Development Boards

Classic Q&A on Embedded ARM Development Boards

Classic Q&A on Embedded ARM Development Boards

Click “Read the original” to enter the ittbank micro mall

Classic Q&A on Embedded ARM Development Boards

Leave a Comment