Chinaunix首页 | 论坛 | 博客
  • 博客访问: 153963
  • 博文数量: 37
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 380
  • 用 户 组: 普通用户
  • 注册时间: 2008-08-13 18:49
文章分类

全部博文(37)

文章存档

2010年(1)

2009年(19)

2008年(17)

我的朋友

分类:

2008-09-24 16:05:06

我想很多希望了解一下arm的bootload的新手肯定会遇到第一个最简单的led试验。

我也一样。我使用的是广州友善之臂的sbc2410开发板。

接下来便开始实现第一个led试验。为此我参考了牛人“Liu Qingmin”的文章
“http://blog.chinaunix.net/u/21948/showart.php?id=350260”。

但是make,烧进去以后发现灯完全没有反应。

他的代码如下

/*
 * Name    : led_on.s
 * Disc    : simple led example
 * 2007-07-30 by Qingmin Liu
 */

@ register address
.equ WTCON,    0x53000000
.equ GPFCON,    0x56000050
.equ GPFUP, 0x56000058
.equ GPFDAT, 0x56000054

@ offset value
.equ oGPFDAT,    0x04

@ macro defination LED_ON
@ you should initial IO pins about leds in order to use this macro
.macro LED_ON led_value
    ldr r1, =\led_value
    str r1, [r0, #oGPFDAT]
    bl delay
.endm

.text
.global _start    @ specified by GNU ld. Here is
        @ ultimately 0x00000000,and you
        @ can fine this in Makefile.

_start:
    @ disable watch dog timer
    @ otherwise mcu will reset at fixed interval, and
    @ you will find led on and off in abnormal way.
    mov r0, #WTCON
    mov r1, #0x00
    str r1, [r0]

    @ initial IO pins: GPF[7:4]
    @ please read datasheet
    ldr r0, =GPFCON
    ldr r1, =0x5500
    str r1, [r0]
    

    ldr r0, =GPFUP
    ldr r1, =0xff
    str r1, [r0]
    
    ldr r0, =GPFDAT
    ldr r1, =0xf
    str r1, [r0]

    @ start to light the leds
    @ led on when low voltage
1:
    LED_ON 0xd0
    LED_ON 0x70
    LED_ON 0xe0
    LED_ON 0xb0
    
    b 1b

    @ meaningless but readable
stop:
    b stop

@
@ SUB Routine
@

@ not accurately, but good effect
delay:
    mov r2, #0x10000
2:
    subs r2, r2, #0x1
    bne 2b

    mov pc, lr

.end

@ "1" and "2" are local symbols. This is supported by Gnu as.
@ If you want to learn more, follow below:
@ (1) $ man as
@ (2) read "using as -- the GNU assembler"

也不明白到底是什么原因,后来用参考了"thisway.diy@163.com"的"S3C2410完全开发流程"一书,发现可以亮一个灯,于是便重点研究了一下。

代码很简洁

.text
.global _start
_start:
    LDR R0,=0x56000010                     @R0设为GPBCON寄存器。此寄存器
                              @用于选择端口B各引脚的功能:
                              @是输出、是输入、还是其他
    MOV R1,#0x00004000
    STR R1,[R0]                                 @设置GPB7为输出口
    LDR R0,=0x56000014                     @R0设为GPBDAT寄存器。此寄存器
                              @用于读/写端口B各引脚的数据
    MOV R1,#0x00000000                     @此值改为0x00000080,
                              @可让LED1熄灭
    STR R1,[R0]                                 @GPB7输出0,LED1点亮
    MAIN_LOOP:
    B MAIN_LOOP

根据LDR R0,=0x56000010 @R0设为GPBCON寄存器,而不是上面使用的GPF端口。然后查阅了官方的手册”SBC2410硬件使用手册“。发现如下

LED1 nXDREQ1/GPB7
LED2 nXDREQ0/GPB8
LED3 nXDACK1/GPB9
LED4 nXDACK0/GPB10

于是注意到

 MOV R1,#0x00004000

这一句。

分析后改为 MOV R1,#0x00154000

然后make并烧入板内,四个灯全部亮起来。done

文件:我的源代码.zip
大小:0KB
下载:下载

文件:S3C2410完全开发流程.pdf
大小:419KB
下载:下载

阅读(1071) | 评论(0) | 转发(0) |
0

上一篇:LanMsg

下一篇:UART实验心得

给主人留下些什么吧!~~