In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
How to use assembly language to light up a LED in Linux driver development, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
The circuit schematic diagram is as follows:
Among them, the LED is connected to the GPF4 port of 2440, and the GPF4 port outputs low-level LED to light up.
The GPF port information of the S3C2440A chip is as follows:
The assembly language is as follows:
@ *
@ File:led_on.S
@ function: LED lighting program, lighting LED1
@ *
.text
.global _ start
_ start:
LDR R0 reference 0x56000050 @ R0 is set to the GPFCON register. This register
@ the function used to select each pin of port B:
@ whether it is output, input, or something else
MOV R1,#0x00000100
STR R1, [R0] @ sets GPF4 as the output, bit [8:7] = 0b01
LDR R0 reference 0x56000054 @ R0 is set to the GPBDAT register. This register
@ data used to read / write port B pins
MOV R1 description 0x00000000 @ this value is changed to 0x00000010
@ enable LED1 to be extinguished
STR R1, [R0] @ GPF4 output 0meme LED1 light up
MAIN_LOOP:
B MAIN_LOOP
The main instructions in the code explain:
@ everything after that is a comment
.text: is a pseudo instruction, indicating that the following statements belong to code snippets
.global: define a program label in this file as global. For example, the above code indicates that _ start is a global function.
LDR: a wide range of address reading directives
LDR R0, = 0x56000050 / / means that the GPF port configuration register address 0x56000050 (constant) is assigned to register R0
MOV: you can assign the value of one register to another, or assign a constant to a register
MOV R1, # 0x00000100 / / # assign the constant 0x00000100 to register R1
STR: stores values in registers into memory
STR R1, [R0] / / saves the data in the R1 register to the memory unit with the address R0; in fact, it saves the 0x00000100 data to the GPF pin configuration address 0x56000050, thus completing the configuration of the GPF pin, that is, configuring the GPF4 pin as the output pin.
LDR R0, = 0x56000054 / / means that the GPF port data register address 0x56000050 (constant) is assigned to register R0
MOV R1, # 0x00000000 / / assign the constant 0x00000000 to register R1
STR R1, [R0] / / saves the data in the R1 register to the memory unit with the address R0; in fact, it saves the 0x00000000 data to the memory address 0x56000054, which makes the GPF4 output low.
B: jump instruction, you can achieve the jump function in the program; first define a code block MAIN_LOOP in the program, and then jump to MAIN_LOOP, endless loop, where the program has been executed.
The Makefile file is as follows:
Led_on.bin: led_on.S
Arm-linux-gcc-g-c-o led_on.o led_on.S
Arm-linux-ld-Ttext 0x0000000-g led_on.o-o led_on_elf
Arm-linux-objcopy-O binary-S led_on_elf led_on.bin
Clean:
Rm-f led_on.bin led_on_elf * .o
Main instructions are as follows:
Arm-linux-gcc: a cross-compilation tool that preprocesses, compiles and assembles the assembly source file led_on.S to generate the OBJ object file led_on.o
Arm-linux-ld: used to connect multiple object files and library files into executable files.
Arm-linux-objcopy: used to copy the contents of one target file to another file, you can output the destination file in a format different from the source file, that is, you can convert the format.
After editing the source code, you can copy the source code and the Makefile file into Ubuntu, and then execute the make command to generate the led_on.bin file. Finally, the target file is burned and written to the development board.
This is the answer to the question about how to use assembly language to light up a LED in Linux driver development. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.