发布时间:2010-10-14 来 源:西谱电子(www.supermcu.com)
/*
实验目的:掌握LPC213X对两个按键识别的编程方法
实验内容:通过连接在LPC2132引脚上的P0.16和P0.14引脚上的按键实现对计数值的加1和减1操作
实验平台:SP1010-LPC213X-ARM实验开发板,FOSC=12MHZ->CCLK=60MHZ,PCLK=CCLK/4
更多内容:www.supermcu.com (西谱电子)
*/
#include <LPC213X.H>
#define ADD_KEY 16
#define SUB_KEY 14
int main(void)
{
long i;
unsigned char KeyCounter = 0x80;
IO1DIR |= (0xFF << 16);
IO1CLR |= (0xFF << 16);
IO1SET |= (~KeyCounter << 16);
while(1)
{
if(0 == (IO0PIN & (1 << ADD_KEY)))
{
for(i=0;i<5000;i++)
if(0 == (IO0PIN & (1 << ADD_KEY)))
{
KeyCounter ++;
IO1CLR |= (0xFF << 16);
IO1SET |= (~KeyCounter << 16);
while(0 == (IO0PIN & (1 << ADD_KEY)));
}
}
if(0 == (IO0PIN & (1 << SUB_KEY)))
{
for(i=0;i<5000;i++)
if(0 == (IO0PIN & (1 << SUB_KEY)))
{
KeyCounter --;
IO1CLR |= (0xFF << 16);
IO1SET |= (~KeyCounter << 16);
while(0 == (IO0PIN & (1 << SUB_KEY)));
}
}
}
}
/*
更多内容:www.supermcu.com (西谱电子)
*/
文章评论(0条评论)
登录后参与讨论