用mini2440开发板做一个LED灯间隔亮与灭的程序,但是达不到实验效果,求解!
起始段汇编代码,在led.s文件中
/*the file function is jump to c program*/
.text
.global _start
_start:
ldr r0, =0x53000000 /*watch dog resgister*/
mov r1, #0x0
str r1, [r0] /*turn off watch dog*/
ldr sp, =1024*4 /*set the stack*/
bl main /*jump to c program*/
halt_loop:
b halt_loop
main函数实现led灯的亮与灭,在led.c文件中
#define rGPBCON (*(volatile unsigned long *) 0x56000010)
#define rGPBDAT (*(volatile unsigned long *) 0x56000014)
void Led_port_init(void);
#define LED1_ON ~(1<<5)
#define LED2_ON ~(1<<6)
#define LED3_ON ~(1<<7)
#define LED4_ON ~(1<<8)
#define LED1_OFF (1<<5)
#define LED2_OFF (1<<6)
#define LED3_OFF (1<<7)
#define LED4_OFF (1<<8)
/*************************************************
Function name: delay
Parameter : times
Description : 延时函数
Return : void
Argument : void
Autor & date :
**************************************************/
void delay(int times)
{
int i;
for(;times>0;times--)
for(i=0;i<400;i++);
}
/*************************************************
Function name: Main
Parameter : void
Description : 主功能函数
Return : void
Argument : void
Autor & date :
**************************************************/
int main(void)
{
int i;
Led_port_init();
for(i=0;i<100;i++)
{
/* 全亮*/
rGPBDAT = rGPBDAT&(LED1_ON)&(LED2_ON)&(LED3_ON)&(LED4_ON);
delay(10000);
/* 全灭*/
rGPBDAT = rGPBDAT|(LED1_OFF)|(LED2_OFF)|(LED3_OFF)|(LED4_OFF);
delay(10000);
}
}
/*************************************************
Function name: Led_port_init
Parameter : void
Description : mini2440开发板有个引脚连接了LED发光
二极管,分别是GPB5--LED1,GPB6—LED2
GPB7--LED3,GPB8--LED4,该函数的作用
是对其个引脚进行初始化。
Return : void
Argument : void
Autor & date : Daniel
**************************************************/
void Led_port_init(void)
{
/*设置GPB5-GPB8为输出端口*/
rGPBCON &= ~((3<<10)|(3<<12)|(3<<14)|(3<<16));
rGPBCON |= (1<<10)|(1<<12)|(1<<14)|(1<<16);
}
makefile文件
led_on.bin : led.s led.c
arm-linux-gcc -c -o led0.o led.s
arm-linux-gcc -c -o led1.o led.c
arm-linux-ld -Ttext 0x0000000 led0.o led1.o -o led_on
arm-linux-objcopy -O binary -S led_on led_on.bin
arm-linux-objdump -D -m arm led_on > log
clean:
rm -f log led_on.bin led_on *.o
能够正确编译,就是不出实验结果。检查了好久都感觉没错,求大家的帮助!