刚学用C语言编程,请各位师傅、前辈帮我看看这段程序。我一直编译不过去!!谢谢了!! #include <reg52.h> #include <lcd16*2.h> void LCD_instruction(); void LCD_data(unsigned char *display); void checkbusy(); void LcdDataLatch(unsigned char lcddata) void cls(); void inital(void); unsigned char ReadStatus(void); void delay(void); void delaykey(); void ScanKey();
unsignde char display[8]; unsign char second; unsign char minite; unsign char hour; unsign char temp;
sbit P31=P3^1; sbit P32=P3^2; sbit P33=P3^3; sbit P34=P3^4; sbit P36=P3^6; sbit P37=P3^7; sbit RS=P1^1; sbit R_W=P1^2; sbit ENABLE=P1^0; sbit Lineout0=P1^4; sbit Lineout1=P1^5; sbit Linein0=P1^6; sbit Linein1=P1^7; unsigned bdata getkey=0; sbit key_left=getkey^0; sbit key_right=getkey^1; sbit key_up=getkey^2; sbit key_down=getkey^3; sbit key_int0=getkey^4;
void main { TMOD=0X02; TH0=0X06; TL0=0X06; EA==1; TR0=1; ET0=1; while(1) { Scankey(); }
}
void ScanKey() { int flag=0; getkey=0; Lineout0=0;//扫描key_up,key_left Lineout1=1; Linein0=1; Linein1=1; delaykey(); if(Linein0==0) { key_up=1; flag=1; while(flag) { if(Linein1==0) { key_left=1; sceond++ if(sceond==60)sceond=0; } Lineout0=1; //扫描key_down,key_right Lineout1=0; Linein0=1; Linein1=1;
delaykey(); if(Linein0==0) { key_down=1; minite++ if(minite==60)minite=0; } if(Linein1==0) { key_right=1; hour++ if(hour==60)hour=0; } Lineout0=0; Lineout1=1; Linein0=1; Linein1=1; if(Linein0==0)//扫描key_up flag=0; disp();
}//end while }//end if // return getkey;//返回键值 */ }
void to(void)interrupt 1 using 0
{ temp++; if(temp==4000) { temp=0; second++ if(second==60) { second==0; minite++; if(minite==60) { minite=0; hour++; if(hour==24) { hour=0; } } } } disp(); }
void disp() // 显示
{ unsigned char i,j; intinal(); cls(); checkbusy(); lcd_instruction(0x80); lcd_data(display); for(i=0;i<3;i++) for(j=0;j<250;j++) delay(); display[0]=second%10+0x30; display[1]=second/10+0x30; display[2]=0X3A; display[3]=minite%10+0x30; display[4]=minite/10+0x30; display[5]=0x3A; display[6]=hour%10+0x30; display[7]=hour/10+0x30;
}
void intinal() { unsigned char data1; data1=0x38;//A,#00111000B Write_instruction(data1); data1=0x0c;//A,#00001100B Write_instruction(data1); data1=0x06;//A,#00000110B Write_instruction(data1);
}
void cls(void) { Write_instruction(0x01); }
void CheckBusy() { unsigned char j=0; ENABLE=0; R_W=1; RS=0; ENABLE=1; for(j=0;j<8;j++) DELAY(); }
void lcd_instruction(unsigned char data1) { CheckBusy(); ENABLE=0; R_W=0; RS=0; ENABLE=1; LcdDataLatch(data1); ENABLE=0; }
void lcd_data(display) { unsigned char i=0; while(i<8) { WriteLCDData(display); i++; } }
void WriteLCDData(unsigned char data1) { CheckBusy(); ENABLE=0; R_W=0; RS=1; ENABLE=1; LcdDataLatch(data1); ENABLE=0; }
void delay() { unsigned char i,j; for(i=0;i<3;i++) for(j=0;j<248;j++)//j<248 ; } void LcdDataLatch(unsigned char lcddata) { unsigned char i=10; P2=0; P2=0x60; P0=lcddata; while(i) i--; P2=0; } |