keil c51 的问题 我这样写为什么编译时"led" - 0 Error(s), 2 Warning(s).
#include<reg52.h>sbitADDR0=P1^0;sbitADDR1=P1^1;sbitADDR2=P1^2;sbitADDR3=P1^3;sbitENLE...
#include <reg52.h>
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;
unsigned char code A[] = {
0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7
};
void main()
{
unsigned char i=0;
ENLED = 0;
ADDR3 = 0;
P0 = 0xFF;
switch(i)
{
case 0: ADDR2=0; ADDR1=0; ADDR0=0; i++; P0=A[0];break;
case 1: ADDR2=0; ADDR1=0; ADDR0=1; i++; P0=A[1];break;
case 2: ADDR2=0; ADDR1=1; ADDR0=0; i++; P0=A[2];break;
case 3: ADDR2=0; ADDR1=1; ADDR0=1; i++; P0=A[3];break;
case 4: ADDR2=1; ADDR1=0; ADDR0=0; i++; P0=A[4];break;
case 5: ADDR2=1; ADDR1=0; ADDR0=1; i++; P0=A[5];break;
case 6: ADDR2=1; ADDR1=1; ADDR0=0; i++; P0=A[6];break;
case 7: ADDR2=1; ADDR1=1; ADDR0=1; i=0; P0=A[7];break;
default: break;
}
} 展开
sbit ADDR0 = P1^0;
sbit ADDR1 = P1^1;
sbit ADDR2 = P1^2;
sbit ADDR3 = P1^3;
sbit ENLED = P1^4;
unsigned char code A[] = {
0xFF,0x99,0x00,0x00,0x00,0x81,0xC3,0xE7
};
void main()
{
unsigned char i=0;
ENLED = 0;
ADDR3 = 0;
P0 = 0xFF;
switch(i)
{
case 0: ADDR2=0; ADDR1=0; ADDR0=0; i++; P0=A[0];break;
case 1: ADDR2=0; ADDR1=0; ADDR0=1; i++; P0=A[1];break;
case 2: ADDR2=0; ADDR1=1; ADDR0=0; i++; P0=A[2];break;
case 3: ADDR2=0; ADDR1=1; ADDR0=1; i++; P0=A[3];break;
case 4: ADDR2=1; ADDR1=0; ADDR0=0; i++; P0=A[4];break;
case 5: ADDR2=1; ADDR1=0; ADDR0=1; i++; P0=A[5];break;
case 6: ADDR2=1; ADDR1=1; ADDR0=0; i++; P0=A[6];break;
case 7: ADDR2=1; ADDR1=1; ADDR0=1; i=0; P0=A[7];break;
default: break;
}
} 展开
1个回答
展开全部
你的程序编译显示0个错误2个警告,但是没有看出警告在那里,这个程序应该没有问,但是我把代码复制到的我工程文件里面便于了一下没有发现警告,你在看看是不是你编译问题,下面是我的编译输出:
compiling Media.c...
linking...
Program Size: data=9.0 xdata=0 code=160
creating hex file from "Media"...
"Media" - 0 Error(s), 0 Warning(s).
compiling Media.c...
linking...
Program Size: data=9.0 xdata=0 code=160
creating hex file from "Media"...
"Media" - 0 Error(s), 0 Warning(s).
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询