JZ2440學習筆記 03 裸機點亮LED燈

1、裸機點LED燈思路:

  a、配置引腳爲輸出模式

  b、設置相應引腳寄存器的輸出狀態(0/1)

2、原理圖可知3個LED分別鏈接在芯片GPF四、GPF5和GPF6引腳上,當引腳輸出0,電路導通,相應的LED被點亮。

3、相關的GPIO寄存器的配置

   芯片手冊主要看兩點

    a、寄存器地址linux

    b、寄存器狀態對應的bit位(0/1)ide

4、代碼

  a、彙編代碼

 1 /*
 2 *點亮led燈:GPF四、GPF五、GPF6
 3 */
 4 
 5 .text
 6 .global _start
 7 
 8 _start:
 9 
10 /*
11 *配置GPF四、GPF五、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
相關文章
相關標籤/搜索