当前位置:网站首页>Imx6ull bare metal development learning 1-assembly lit LED
Imx6ull bare metal development learning 1-assembly lit LED
2022-07-05 08:04:00 【Changjiang houlang blog】
adopt GNU ARM Assembly implementation is right led Light flashing control .
Programming environment building :
Development board : Wildfire Imx6ull mini plate
Programming environment :Ubuntu18.04 + VScode
Assemble the code directly :
/*******************
* file name : led.s
* author : Guizhiwei
* mailbox : [email protected]
* describe : Bare metal experimental test 1 Assembly light up led The lamp
********************/
.global _start @ Global label
/*****
* describe : _start function
*/
_start :
/*****
* Lighten up LED The lamp GPIO5_IO03
* Open drain output
*/
/*****
*1. Enable to control the clock
*/
ldr r0, =0x020c4068 @ Configuration register CCM_CCGR0
ldr r1, =0xffffffff
str r1, [r0]
ldr r0, =0x020c406C @ Configuration register CCM_CCGR1
ldr r1, =0xffffffff
str r1, [r0]
ldr r0, =0x020c4070 @ Configuration register CCM_CCGR2
ldr r1, =0xffffffff
str r1, [r0]
ldr r0, =0x020c4074 @ Configuration register CCM_CCGR3
ldr r1, =0xffffffff
str r1, [r0]
ldr r0, =0x020c4078 @ Configuration register CCM_CCGR4
ldr r1, =0xffffffff
str r1, [r0]
ldr r0, =0x020c407C @ Configuration register CCM_CCGR5
ldr r1, =0xffffffff
str r1, [r0]
ldr r0, =0x020c4080 @ Configuration register CCM_CCGR6
ldr r1, =0xffffffff
str r1, [r0]
/*****
*2.GPIO5_IO03 Reuse function configuration GPIO
*IOMUXC_SNVS_SW_MUX_CTL_PAD_SNVS_TAMPER3 Address 229_0014h
*/
ldr r0, =0x02290014 @ Configuration register SNVS_TAMPER3
ldr r1, =0x5 @AL5
str r1, [r0]
/*****
*3.GPIO5_IO03 To configure IO Property function
*IOMUXC_SNVS_SW_PAD_CTL_PAD_SNVS_TAMPER3 Address 229_0058h
*BIT0 Swaying rate 0- Slow down
*BIT5-3 Driving ability R0/6 -110
*BIT7-6 Speed 100mhz-10
* BIT11 Open drain output enable 1- Turn on
*BIT12 The pull-down function is enabled 0- Close the pull-down button
*BIT13 Keep function 0
*BIT15-14 100K Up and down resistance -00
*BIT16 hys-0 close
* Set the configuration value :8B0-100010110000
*/
ldr r0, =0x02290058 @ Configuration register SNVS_TAMPER3
ldr r1, =0x08B0 @AL5
str r1, [r0]
/*****
*4. Set up GPIO5_IO03 For export
*GPIO5_GDIR Address 20A_C004
*GPIO5_DR Address 20A_C000
*/
ldr r0, =0x020AC004 @ Configuration register GPIO5_GDIR
ldr r1, =0x08 @BIT3
str r1, [r0]
/*****
*5 open GPIO LED
*/
ldr r0, =0x020AC000 @GPIO5_DR
ldr r1, =0x00 @BIT3
str r1, [r0]
/*****
*6 loop Cycling
*/
loop:
/**
* turn on the light
*/
ldr r0, =0x020AC000 @GPIO5_DR
ldr r1, =0x00 @BIT3
str r1, [r0]
/**
* Time delay
*/
bl delay
/**
* Turn off the lights
*/
ldr r0, =0x020AC000 @GPIO5_DR
ldr r1, =0x08 @BIT3
str r1, [r0]
/**
* Time delay
*/
bl delay
b loop
/**
* Time delay
*/
delay:
ldr r2, =0xfffff
ldr r3, =0x0
delay_loop:
sub r2,r2, #1
cmp r2,r3
bne delay_loop
mov pc,lr @ Return the main function
A simplified version of makefie
led.bin : led.s
arm-linux-gnueabihf-gcc -g -c led.s -o led.o
arm-linux-gnueabihf-ld -Ttext 0x87800000 led.o -o led.elf
arm-linux-gnueabihf-objcopy -O binary -S -g led.elf led.bin
clean:
rm -rf *.o led.bin led.elf led.dis
dump:
arm-linux-gnueabihf-objdump -D led.elf > led.dis
dowmload:
./imxdownload led.bin /dev/sdb
Final effect :
Probably 0.5s Time flashing .
Simple assembly delay code :
/**
* Time delay
*/
delay:
ldr r2, =0xfffff
ldr r3, =0x0
delay_loop:
sub r2,r2, #1
cmp r2,r3
bne delay_loop
mov pc,lr @ Return the main function 边栏推荐
- After installing the new version of keil5 or upgrading the JLINK firmware, you will always be prompted about the firmware update
- Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
- Shape template matching based on Halcon learning [vi] find_ mirror_ dies. Hdev routine
- Global and Chinese market of blackbody calibration source 2022-2028: Research Report on technology, participants, trends, market size and share
- 万字详解八大排序 必读(代码+动图演示)
- Global and Chinese markets for flexible endoscopic lithotripsy devices 2022-2028: Research Report on technology, participants, trends, market size and share
- The firmware of the connected j-link does not support the following memory access
- Gradle复合构建
- 1-stm32 operation environment construction
- Record the visual shock of the Winter Olympics and the introduction of the screen 2
猜你喜欢

Embedded composition and route

Factors affecting the quality of slip rings in production

Ads usage skills

Network port usage
![C WinForm [view status bar -- statusstrip] - Practice 2](/img/40/63065e6c4dc4e9fcb3e898981f518a.jpg)
C WinForm [view status bar -- statusstrip] - Practice 2

C, Numerical Recipes in C, solution of linear algebraic equations, LU decomposition source program

Ads learning record (lna_atf54143)

Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)

The printer encountered an abnormal configuration problem 0x8007007e (win10)

C#,数值计算(Numerical Recipes in C#),线性代数方程的求解,LU分解(LU Decomposition)源程序
随机推荐
Verilog -- state machine coding method
Nb-iot technical summary
Process communication mode between different hosts -- socket
Record the visual shock of the Winter Olympics and the introduction of the screen 2
研究发现,跨境电商客服系统都有这五点功能!
Acwing - the collection of pet elves - (multidimensional 01 Backpack + positive and reverse order + two forms of DP for the answer)
About yolov3, conduct map test directly
Altium designer 19.1.18 - hide the fly line of a network
Altium designer learning (I)
C WinForm [exit application] - practice 3
C WinForm [get file path -- traverse folder pictures] - practical exercise 6
Cadence learning records
[trio basic tutorial 18 from introduction to proficiency] trio motion controller UDP fast exchange data communication
Global and Chinese markets of nano biosensors 2022-2028: Research Report on technology, participants, trends, market size and share
About the problem that MySQL connector net cannot be cleared in MySQL
Shape template matching based on Halcon learning [vi] find_ mirror_ dies. Hdev routine
Basic embedded concepts
Extern keyword function
软件设计师:03-数据库系统
C language uses arrays to realize the intersection, union, difference and complement of sets