;汇编程序:
IMPORT Main
AREA Init,CODE,READONLY
ENTRY
_start
; 关闭看门狗
LDR R0,=0X53000000
MOV R1,#0
STR R1,[R0]
; 设置堆栈在 stepping stone的末端
LDR R0,=(0x40000000+1024*4)
MOV SP,R0
; 调用 C 的main 函数
BL Main
END
//c语言:
#define GPBCON (*(volatile unsigned long *)0x56000010)
#define GPBDAT (*(volatile unsigned long *)0x56000014)
#define GPB5_out (1<<(5*2))
#define GPB6_out (1<<(6*2))
#define GPB7_out (1<<(7*2))
#define GPB8_out (1<<(8*2))
// 延时函数
void wait(unsigned long dly)
{
for(; dly > 0; dly--);
}
int Main(int argc,char **argv)
{
unsigned long i = 0;
GPBCON = GPB5_out|GPB6_out|GPB7_out|GPB8_out; // 将LED1-4对应的GPB5/6/7/8四个引脚设为输出
while(1){
wait(200000);
GPBDAT = (~(i<<5)); // 根据i的值,点亮LED1-4
if(++i == 16)
i = 0;
}
return 0;
}
//RO=30000000