OK6410裸机汇编:1th_led
2018-10-12 来源:eefocus
start.S文件:
.globl _start
_start:
1、硬件相关的设置:
把外设的基地址告诉CPU,因为内存和外设寄存器的访问方式不同,所以要告诉CPU外设地址范围:
0 ~ 0x6fff ffff为内存的地址空间,0x7000 0000 ~ 0x7fff ffff为外设寄存器的地址空间
ldr r0, =0x70000000
orr r0, r0, #0x13
mcr p15,0,r0,c15,c2,4 @ 256M(0x70000000-0x7fffffff)
2、关看门狗 ,往WTCON(0x7E004000)写0
ldr r0, =0x7E004000
mov r1, #0
str r1, [r0]
3、设置GPMCON让GPM3作为输出引脚
ldr r1, =0x7F008820
mov r0, #0x1000
str r0, [r1]
4、设置GPMDAT让GPM3输出0
ldr r1, =0x7F008824
mov r0, #0
str r0, [r1]
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 //-c只编译不链接
clean:
rm *.o led.elf led.bin led.dis
=====================================================================
下载测试,下载方法可以参考“烧写OK6410裸板方法汇总”章节介绍:
用SecureCRT下载led.bin:
tftp 0x50008000 led.bin
go 0x50008000
即可看到程序运行效果。