分类: 嵌入式
2009-12-27 22:47:36
打开DebugRel Settings(ALT + F7),选择”ARM Linker”, 选择”Linktype为Simple”,将”Simple image”的”RO Base”改为0x30000000。设置“Equvalent Command Line”为:
-info totals -entry 0x30000000 -ro-base 0x30000000 -first Init.o(Init)
//init.s IMP
CO
AREA Init,CO
ENTRY
ldr r0, =0x53000000
mov r1, #0x0
str r1, [r0]
ldr sp, =1024 * 4
bl main
main_loop
b main_loop
END
//main.c
#define GPBCON (*(volatile unsigned long *)0x56000010)
#define GPBDAT (*(volatile unsigned long *)0x56000014)
#define LED1 (1 << (5 * 2))
#define LED2 (1 << (6 * 2))
#define LED3 (1 << (7 * 2))
#define LED4 (1 << (8 * 2))
#define LEDS (LED1 | LED2 | LED3 | LED4)
void delay(int dly);
int main()
{
int flag = 0;
GPBCON = LEDS;
while (1) {
if (flag) {
GPBDAT = 0xffffffff;
flag = 0;
} else {
GPBDAT = 0x00000000;
flag = 1;
}
delay(120);
}
return 0;
}
void delay(int dly)
{
int i;
for (;dly > 0; dly--)
for (i = 0;i < 10000; i++);
}