#include <REGX51.H>
sbit AA=P1^0; //38译码器输入
sbit BB=P1^1; //38译码器输入
sbit CC=P1^2; //38译码器输入
#define DUANXUAN=P0; //数码管段选
typedef unsigned int uint16;
typedef unsigned char uint8;
uint8 BUFF[]={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
uint8 code CODE[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0x88,0x83,0xC6,0xA1,0x86,0x8E};
main()
{
uint16 sec=0;
uint16 cnt=0;
uint8 i=0;
TMOD=0x01;
TH0 =0xFC;
TL0 =0x67;
TR0 =1;
while(1)
{
if(1==TF0)
{
TF0=0;
TH0=0xFC;
TL0=0x67;
cnt++;
if(1000==cnt)
{
cnt=0;
sec++;
}
}
BUFF[0]=CODE[sec%10];
BUFF[1]=CODE[sec/10%10];
BUFF[2]=CODE[sec/100%10];
BUFF[3]=CODE[sec/1000%10];
BUFF[4]=CODE[sec/10000%10];
BUFF[5]=CODE[sec/100000%10];
if (0==i)
{ AA=0;BB=0;CC=0;i++;DUANXUAN[0]; }
else if(1==i)
{ AA=1;BB=0;CC=0;i++;DUANXUAN[0]; }
else if(2==i)
{ AA=0;BB=1;CC=0;i++;DUANXUAN[0]; }
else if(3==i)
{ AA=1;BB=1;CC=0;i++;DUANXUAN[0]; }
else if(4==i)
{ AA=0;BB=0;CC=1;i++;DUANXUAN[0]; }
else if(5==i)
{ AA=1;BB=0;CC=1;i++;DUANXUAN[0]; }
编译输出:Build target 'Target 1'
compiling 138yima.c...
138YIMA.C(43): error C141: syntax error near '='
138YIMA.C(43): error C141: syntax error near '['
138YIMA.C(43): error C141: syntax error near ']'
138YIMA.C(45): error C141: syntax error near '='
138YIMA.C(45): error C141: syntax error near '['
138YIMA.C(45): error C141: syntax error near ']'
138YIMA.C(47): error C141: syntax error near '='
138YIMA.C(47): error C141: syntax error near '['
138YIMA.C(47): error C141: syntax error near ']'
138YIMA.C(49): error C141: syntax error near '='
138YIMA.C(49): error C141: syntax error near '['
138YIMA.C(49): error C141: syntax error near ']'
138YIMA.C(51): error C141: syntax error near '='
138YIMA.C(51): error C141: syntax error near '['
138YIMA.C(51): error C141: syntax error near ']'
138YIMA.C(53): error C141: syntax error near '='
138YIMA.C(53): error C141: syntax error near '['
138YIMA.C(53): error C141: syntax error near ']'
Target not created
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
谢谢,确实基础很差。有待加强。
一周热门 更多>