s3c2440 --跑馬燈 C+匯編代碼
/*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); /*聲明匯編函數(shù)*/
int main()
{
/*設(shè)置 GPFCON*/
rGPFCON &= 0x00ff; //GPF4 - 7置為 0
rGPFCON |= 0x55ff; //GPF4 - 7置為 output
/*設(shè)置 GPFUP*/
rGPFUP |= 0xff00;
while(1)
{
/*亮燈 GPF4*/
rGPFDAT |= 0xf0; //GPF4 - 7置為 1
rGPFDAT &= 0xe0;//GPF4置為 0
delay(0x1ffffff); //調(diào)用匯編程序?qū)懙难訒r(shí)程序
/*亮燈 GPF5*/
rGPFDAT |= 0xf0; //GPF4 - 7置為 1
rGPFDAT &= 0xd0;//GPF5置為 0
delay(0x1ffffff); //調(diào)用匯編程序?qū)懙难訒r(shí)程序
/*亮燈 GPF6*/
rGPFDAT |= 0xf0; //GPF4 - 7置為 1
rGPFDAT &= 0xb0;//GPF6置為 0
delay(0x1ffffff); //調(diào)用匯編程序?qū)懙难訒r(shí)程序
/*亮燈 GPF7*/
rGPFDAT |= 0xf0; //GPF4 - 7置為 1
rGPFDAT &= 0x70;//GPF7置為 0
delay(0x1ffffff); //調(diào)用匯編程序?qū)懙难訒r(shí)程序
}
}
;delay.s
EXPORT delay
AREA delay1,CODE ,READONLY ;該偽指令定義了一個(gè)代碼段 delay1這個(gè)名字要注意
;下面延時(shí)子程序
ENTRY
delay
;傳一個(gè)參數(shù) ,參數(shù)放到 r0
sub r0 ,r0 ,#1
cmp r0 ,#0x0
bne delay ;result is not 0 and continue delay
mov pc ,lr ;return
END; //end