下面的代码是从下载的,在我的板子上试了一下,LED1不亮,对汇编不熟悉,暂不知怎么修改。
出来:
基于s3c6410的tiny6410的led裸机程序源代码,
1 对Led灯的操作
.globl _start
_start:
/* 硬件相关的设置 */
/* Peri port setup */
ldr r0, =0x70000000
orr r0, r0, #0x13
mcr p15,0,r0,c15,c2,4 @ 256M(0x70000000-0x7fffffff)
/* 关看门狗 */
/* 往WTCON(0x7E004000)写0 */
ldr r0, =0x7E004000
mov r1, #0
str r1, [r0]
/* 设置GPMCON让GPM3作为输出引脚 */
ldr r1, =0x7F008800
mov r1, #0x1000
str r1, [r0]
/* 设置GPMDAT让GPM3输出0 */
ldr r1, =0x7F008808
mov r1, #0x0
str r1, [r0]
halt:
b halt
2 循环点亮Led灯的方法
start.S
.globl _start
_start:
// Peripheral Port Setup
ldr r0,=0x70000000
orr r0,r0,#0x13
mcr p15,0,r0,c15,c2,4
// Close Watch Dog
ldr r0,=0x7e004000
mov r1,#0
str r1,[r0]
// Setup GPKCON1
ldr r0,=0x7f008800
ldr r1,=0x11110000
str r1,[r0]
// Setup GPKDAT
ldr r0,=0x7f008808
mov r1,#0x00
str r1,[r0]
// loop
loop:
mov r1,#0x00
mov r2,#0x10
mov r3,#4
loop1:
orr r1,r1,r2
str r1,[r0]
bl delay
mov r2,r2,lsl#1
sub r3,r3,#1
cmp r3,#0
beq loop
b loop1
// delay
delay:
ldr r4,=0x1000000
DelayLoop:
sub r4,r4,#1
cmp r4,#0
bne DelayLoop
mov pc,r14
halt:
b halt
Makefile:
led.bin: start.o
arm-linux-ld -Ttext 0 -o led.elf start.o
arm-linux-objcopy -O binary led.elf led.bin
arm-linux-objdump -D led.elf > led.dis
start.o : start.S
arm-linux-gcc -o start.o start.S -c
clean:
rm *.o led.elf led.bin led.dis