单片机的一个小问题?
#include<reg52.h>
#define DataPort P0;
sbit latch1=P2^3;
sbit latch2=P2^2;
unsigned char code weima[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
unsigned char code duanma[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char tempdata[8];
void delay(unsigned int t);
void display(unsigned char firstbit ,unsigned char num);
void main()
{
unsigned int i;
unsigned char num;
while(1)
{
i++;
if(i==500)
{
i=0;
num++;
if(num==10)
num=0;
}
tempdata[0]=duanma[num%10];
display(4,1);
}
}
void delay(unsigned int t)
{
while(--t);
}
void display(unsigned char firstbit,unsigned char num)
{
unsigned char i;
for(i=0;i<num;i++)
{
DataPort=0;
latch2=1;
latch2=0;
DataPort=weima[i+firstbit];
latch1=1;
latch1=0;
DataPort=tempdata[i];
latch2=1;
latch2=0;
delay(200);
}
}
编译时keil提示DataPort=0;DataPort=weima[i+firstbit]; DataPort=tempdata[i];附近有符号错误,求帮助?
[解决办法]
#define DataPort P0;
改成
#define DataPort P0
去掉分号
[解决办法]