JZ2440学习笔记 03 裸机点亮LED灯

一、裸机点LED灯思路:

  a、配置引脚为输出模式

  b、设置相应引脚寄存器的输出状态(0/1)

二、原理图可知3个LED分别连接在芯片GPF4、GPF5和GPF6引脚上,当引脚输出0,电路导通,相应的LED被点亮。

三、相关的GPIO寄存器的配置

   芯片手册主要看两点

    a、寄存器地址

    b、寄存器状态对应的bit位(0/1)

四、代码

  a、汇编代码

 1 /*
 2 *点亮led灯:GPF4、GPF5、GPF6
 3 */
 4 
 5 .text
 6 .global _start
 7 
 8 _start:
 9 
10 /*
11 *配置GPF4、GPF5、GPF6为输出引脚
12 *把0x100写到地址0x56000050上
13 */
14     ldr r1, =0x56000050
15     ldr r0, =0x1500
16     str r0, [r1]
17 
18 
19 
20 /*
21 *设置GPF4输出高电平
22 *把0x0写到地址0x56000054
23 */
24     ldr r1, =0x56000054
25     ldr r0, =0x20
26     str r0, [r1]
27 
28 
29 /*死循环*/
30 halt:
31     b halt
View Code

  b、Makefile

1 kst:
2     arm-linux-gcc -c -o led_on.o led_on.S
3     arm-linux-ld -Ttext 0 led_on.o -o led_on.elf
4     arm-linux-objcopy -O binary -S led_on.elf led_on.bin
5     
6 zq:
7     rm *.bin *.o *.elf
View Code
原文地址:https://www.cnblogs.com/ksht-wdyx/p/13511175.html