Previously written a little C program on the operating system, can not feel it: BSS segment, the meaning of the stack. To write the program on the microcontroller did not consider these issues. However, it seems that the environment on ARM is not that simple. C's environment must be created on its own, otherwise it cannot be used. This also deeply felt the original incomprehensible concepts in the C language. Bare Metal Build C Environment - Set Stack Pointer This is the first condition of using C language, but this is to specify an SP pointer on it, very simple. Ldr sp, =4096. Bare Metal Establishing C Language Environment - Cleaning up BSS Segments If global variables or static variables are used in the C language, this compile time places them in the BSS section, which is in memory. How was it built? Manually write a linker script and add the __bss_start __bss_end variable to indicate the start and end of the BSS segment. as follows: SECTIONS { . = 0x00000000; .text : { *(.text) } .rodata ALIGN(4) : AT((LOADADDR(.text)+SIZEOF(.text)+3)&~(0x03)) {*(.rodata*)} .data ALIGN(4) : AT((LOADADDR(.rodata)+SIZEOF(.rodata)+3)&~(0x03)) { *(.data) } __bss_start = .; .bss ALIGN(4) : { *(.bss) *(COMMON) } __bss_end = .; } This cleans up the content intrinsic between __bss_start and __bss_end in the application. This global variable can be used, otherwise there will be an exception. The specific behavior I encountered was: the value of a global variable cannot be changed. The code can learn u-boot assembly method cleanup: /* * These are defined in the board-specific linker script. */ .globl _bss_start _bss_start: .word __bss_start .globl _bss_end _bss_end: .word __bss_end /* * Clear BSS segment */ Clear_bss: Ldr r0, _bss_start /* find start of bss segment */ Ldr r1, _bss_end /* stop here */ Mov r2, #0x00000000 /* clear */ Clbss_l:str r2, [r0] /* clear loop... */ Add r0, r0, #4 Cmp r0, r1 Ble clbss_l Mov pc, lr /* end_of clear_bss */ It can also be implemented in C language: Void clean_bss(void) { Extern int __bss_start, __bss_end; Int *p = &__bss_start; For (; p < &__bss_end; p++) *p = 0; } Summary: Write 0 to this memory. A manual pulse generator (MPG) is a device normally associated with computer numerically controlled machinery or other devices involved in positioning. It usually consists of a rotating knob that generates electrical pulses that are sent to an equipment controller. The controller will then move the piece of equipment a predetermined distance for each pulse. Manual Pulse Generator,Handwheel MPG CNC,Electric Pulse Generator,Signal Pulse Generator Jilin Lander Intelligent Technology Co., Ltd , https://www.landerintelligent.com
The CNC handheld controller MPG Pendant with x1, x10, x100 selectable. It is equipped with our popular machined MPG unit, 4,5,6 axis and scale selector, emergency stop and reset button.