|
按键点亮led,这灯肿么不亮啊
#include
#define HWREG(x) (*((volatile unsigned long *)(x)))
int main(void)
{
long a;
SYSCTL_RCGC2_R |= (SYSCTL_RCGC2_GPIOA | SYSCTL_RCGC2_GPIOB); //系统控制,使能GPIO口
GPIO_PORTA_DIR_R = 0x00000001; //使能PD0口,设置为输出 (LED)
GPIO_PORTB_DIR_R = 0x00000000; //使能PE0口,设置为输入 (KEY)
GPIO_PORTA_DEN_R = 0x01; //数字输入使能
// GPIO_PORTB_PDR_R = 0x01; //数字输入使能
GPIO_PORTA_AFSEL_R = 0x00;
GPIO_PORTB_AFSEL_R = 0x00;
while(1)
{
a=HWREG(0x40005000+(0x00000001<<2)); //读数据
if(a == 1)
{
if(a == 1)
{
a = 0;
HWREG(0x40004000+(0x00000001<<2))=0x00000001;// 打开led
}
else
{
a=1;
HWREG(0x40004000+(0x00000001<<2))=0x00000000;} //关闭led
}
}
}
这等则么弄都不亮啊,灯没问题,这开关按下去没反应啊,,,,,
[ 本帖最后由 树儿是魔法师 于 2013-7-13 11:26 编辑 ] |
|