汇编主函数如下
INCLUDE LPC2294.INC ; Include the head file 引入头文件
LEDCON EQU 0x00080000
;声明MAIN函数
;Export MAIN functon
EXPORT MAIN ;MAIN Function主程序
CODE32
AREA a,CODE,READONLY
IMPORT Delay
ENTRY
MAIN
;add the user code here. 添加用户代码
LDR R0,=PINSEL0
LDR R1,=0x00000000
STR R1,[R0]
LDR R0,=PINSEL1
LDR R1,=0x00000000
STR R1,[R0]
LDR R0,=IODIR
LDR R1,=LEDCON
STR R1,[R0]
;LDR R0,=IOCLR
;LDR R1,=LEDCON
;STR R1,[R0]
; LDR R1,=LEDCON
MAIN_LOOP
BL Delay
B MAIN_LOOP
END
C中子函数如下
#include "LPC2103.H"
#define KEY (1<<16)
#define LEDCON (1<<19)
void Delay(void)
{
if ((IOPIN&KEY)==0)
{
IOCLR = LEDCON;
}
else
{
IOSET = LEDCON;
}
}
以上的KEY LENCON必须在C文件中定义 才行
阅读(3595) | 评论(0) | 转发(0) |