根据书中类题编的程序,找不出是什么问题了。。。初学者求指导
#include "config.h"
const uint32 LEDS8=(0xFF<<18);
//P1[25:18]控制LED8~LED1,低电平点亮
const uint32 KEY1 = 1 << 15;
//P0.15连接KEY1
const uint32 KEY2 = 1 << 16;
//P0.16连接KEY2
const uint32 KEY3 = 1 << 17;
//P0.17连接KEY3
const uint32 KEY4 = 1 << 18;
//P0.18连接KEY4
const uint32 LED_1[] = {0x80,0xa0,0xa8,0xaa};
//奇数灯从左至右依次点亮
const uint32 LED_2[] = {0xc0,0xfo,0xfc,0xff};
//偶数灯从左至右依次点亮
const uint32 LED_3[] = {0x7f,0x5f,0x57,0x55};
//奇数灯从左至右依次熄灭
const uint32 LED_4[] = {0x15,0x05,0x01,0x00};
//偶数灯从左至右依次熄灭
/***********************************************************************
**函数名称:DelayNS()
**函数功能:长软件延时
**入口参数:dly延时参数,值越大,延时越久
**出口参数:无
***********************************************************************/
void DelayNS (uint32 dly)
{
uint32 i;
for(;dly>0;dly--)
for(i=0;i<50000;i++);
}
/***********************************************************************
**函数名称:main()
**函数功能:流水灯显示实验
**调用说明:连接跳线JP12至LED8~LED1
***********************************************************************/
/*流水灯花样,低电平点亮,注意调用时用了取反操作*/
int main(void)
{
uint8 i;
PINSEL0 = 0x00000000;
//设置管脚连接GPIO
PINSEL1 = 0x00000000;
//设置管脚连接GPIO
IO1DIR
= LEDS8;
//设置LED控制口为输出
while(1)
{
if((IO1PIN & KEY1) == 0)
//花样1显示
{
for(i=0,i<8;i=i+2)
//奇数亮
{
IO1SET = ~((LED_1[i]) << 18);
DelayNS(100);
}
}
if((IO1PIN & KEY2) == 0)
//花样2显示
{
for(i=0,i<8;i=i+2)
//偶数亮
{
IO1SET = ~((LED_2[i]) << 18);
DelayNS(100);
}
}
if((IO1PIN & KEY3) == 0)
//花样3显示
{
for(i=0,i<8;i=i+2)
{
IO1CLR = ((LED_3[i]) << 18);
DelayNS(100);
}
}
if((IO1PIN & KEY4) == 0)
//花样4显示
{
for(i=0,i<8;i=i+2)
{
IO1CLR = ((LED_4[i]) << 18);
DelayNS(100);
}
}
}
return 0;
}