怎么改都有这个错误DS1302.c(20): error C129: missing ';' before 'LED1'
单片机源程序如下:
- #include <reg52.h>
- #include <intrins.h>
- #define unsigned char u8
- sbit RS=P2^0;
- sbit RW=P2^1;
- sbit E=P1^2;
- sbit T_RST=P1^3;
- sbit T_CLK=P1^7;
- sbit T_IO=P2^3;
- sbit s7=P3^0;
- sbit s6=P3^1;
- sbit s5=P3^2;
- sbit s4=P3^3;
- u8 LED1,LED2,LED4,LED5,LED7,LED8;
- u8 time1,time2,time4,time5,time7,time8;
- u8 select_function;
- unsigned char timechar[]={"TIME:"};
- unsigned char datechar[]={"DATE:"};
- void Timer0Init()
- {
- TMOD=0X01;
- TH0=0XD8;
- TL0=0XF0;
- ET0=1;
- EA=1;
- TR0=1;
- }
- void time_calculate()
- {
- time1++;
- if(time1==60)
- {
- time1=0;
- time2++;
- }
- if(time2==60)
- {
- time2=0;
- time3++;
- }
- if(time3==24)
- {
- time1=0;
- time2=0;
- time3++;
- }
- }
- //*********************************************************************************
- void WriteB(unsigned char dat)
- {
- unsigned char i;
- for(i=8; i>0; i--)
- {
- T_IO=dat&0x01;
- T_CLK = 1;
- T_CLK = 0;
- dat = dat >> 1;
- }
- }
- unsigned char ReadB(void)
- {
- unsigned char i,readdat=0;
- for(i=8; i>0; i--)
- {
- readdat=readdat>>1;
- if(T_IO)
- {
- readdat|=0x80;
- }
- T_CLK = 1;
- T_CLK = 0;
- }
- return(readdat);
- }
- void W1302(unsigned char address,unsigned char dat)
- {
- T_RST = 0;
- T_CLK = 0;
- _nop_();
- _nop_();
- T_RST = 1;
- _nop_();
- _nop_();
- WriteB(address);
- WriteB(dat);
- T_CLK = 1;
- T_RST =0;
- }
- unsigned char R1302(unsigned char address)
- {
- unsigned char dat=0;
- T_RST = 0;
- T_CLK = 0;
- T_RST = 1;
- WriteB(address);
- dat = ReadB();
- T_CLK = 1;
- T_RST =0;
- return(dat);
- }
- void delay(unsigned int n)
- {
- unsigned i=0,j=0;
- for(i=0;i<n;i++)
- {
- for(j=0;j<120;j++);
- }
- }
- void writedat(unsigned char dat)
- {
- RS=1;
- RW=0;
- E=0;
- P0=dat;
- delay(5);
- E=1;
- E=0;
- }
- void writecom(unsigned char com)
- {
- RS=0;
- RW=0;
- E=0;
- P0=com;
- delay(5);
- E=1;
- E=0;
- }
- void Initlcd()
- {
- writecom(0x38);
- writecom(0x0c);
- writecom(0x06);
- writecom(0x01);
- }
- void keypros()
- {
- if(s6==0)
- {
- delay(10);
- if(s6==0)
- {
- select_function++;
- if(select_function==4)select_function=0;
- if(select_function!=0)TRO=0;
- }while(!s6);
- if(select_function==0)TRO=1;
- }
- /**********************************************************/
- if(select_function==1)
- {
- if(s5==0)
- {
- time1++;
- if(time1>=60)time1=0
- }while(!s5);
- if(s4==0)
- {
- if(time1==0)time1=60;
- time1--;
- }while(!s4);
- }
- /**********************************************************/
- if(select_function==2)
- {
- if(s5==0)
- {
- time2++;
- if(time2>=60)time2=0
- }while(!s5);
- if(s4==0)
- {
- if(time2==0)time2=60;
- time2--;
- }while(!s4);
- }
- /**********************************************************/
- if(select_function==3)
- {
- if(s5==0)
- {
- time3++;
- if(time3>=24)time3=0
- }while(!s5);
- if(s4==0)
- {
- if(time3==0)time3=24;
- time3--;
- }while(!s4);
- }
- LED1=time1%10;
- LED1=time1/10;
-
- LED2=time2%10;
- LED2=time2/10;
-
- LED3=time3%10;
- LED3=time3/10;
-
- }
- //************************ÖD¶Ï£¨Ã¿¸ô10msÖD¶Ïò»′Σ¬Ë¢DÂ걼䣩***********
- void Timer0() interrupt 1
- {
- static unsigned int k=0;
- TH0=0xD8;
- TL0=0xF0;
- k++;
- if(k==50)
- {
- k=0;
- timer_calculate();
- }
- }
- //*********************************************************************
- void display()
- {
- lcd_pos(0x07);
- lcdwriteData(LED8+'0');
- lcd_pos(0x08);
- lcdwriteData(LED7+'0');
- lcd_pos(0x09);
- lcewriteData('-');
- /*****************************/
- lcd_pos(0x0A);
- lcdwriteData(LED5+'0');
- lcd_pos(0x0B);
- lcdwriteData(LED4+'0');
- lcd_pos(0x0C);
- lcewriteData('-');
- /****************************/
- lcd_pos(0x0D);
- lcdwriteData(LED2+'0');
- lcd_pos(0x0E);
- lcdwriteData(LED1+'0');
- lcd_pos(0x0F);
- lcewriteData('-');
-
- }
- //***********************************************************************
- //***********************************************************************
- void main()
- {
- Initlcd();
- show_string(display);
- Time0Init();
- LED1=0;
- LED2=0;
- LED3=0;
- LED4=0;
- LED5=0;
- LED6=0;
- LED7=0;
- LED8=0;
- select_function=0;
- time1=0;
- time2=0;
- time3=0;
-
- show_string(display)
- while(1)
- {
- keypros();
- display();
- }
- }
复制代码
|