/*led_asm_c.c*/
#define rGPFCON (*(volatile unsigned *)0x56000050) //Port F control
#define rGPFDAT (*(volatile unsigned *)0x56000054) //Port F data
#define rGPFUP (*(volatile unsigned *)0x56000058) //Pull-up control F
//GPFCON 8口的
extern int delay(int time); /*声明汇编函数*/
int main()
{
/*设置 GPFCON*/
rGPFCON &= 0x00ff; //GPF4 - 7置为 0
rGPFCON |= 0x55ff; //GPF4 - 7置为 output
/*设置 GPFUP*/
rGPFUP |= 0xff00;
while(1)
{
/*亮灯 GPF4*/
rGPFDAT |= 0xf0; //GPF4 - 7置为 1
rGPFDAT &= 0xe0; //GPF4置为 0
delay(0x1ffffff); //调用汇编程序写的延时程序
/*亮灯 GPF5*/
rGPFDAT |= 0xf0; //GPF4 - 7置为 1
rGPFDAT &= 0xd0; //GPF5置为 0
delay(0x1ffffff); //调用汇编程序写的延时程序
/*亮灯 GPF6*/
rGPFDAT |= 0xf0; //GPF4 - 7置为 1
rGPFDAT &= 0xb0; //GPF6置为 0
delay(0x1ffffff); //调用汇编程序写的延时程序
/*亮灯 GPF7*/
rGPFDAT |= 0xf0; //GPF4 - 7置为 1
rGPFDAT &= 0x70; //GPF7置为 0
delay(0x1ffffff); //调用汇编程序写的延时程序
}
}
;delay.s
EXPORT delay
AREA delay1,CODE ,READONLY ;该伪指令定义了一个代码段 delay1这个名字要注意
;下面延时子程序
ENTRY
delay
;传一个参数 ,参数放到 r0
sub r0 ,r0 ,#1
cmp r0 ,#0x0
bne delay ;result is not 0 and continue delay
mov pc ,lr ;return
END; //end