完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
最近做数字钟,写了一段1302的程序,用1602显示。还没加按键部分程序。初步调试结果数字显示出错,求助有经验的朋友,分析一下程序出错的根源。谢谢。 程序如下: #include #define uc unsigned char ***it rs=P3^5; ***it wr=P3^6; //1602 bit definitions ***it lcden=P3^4; ***it dula=P2^6; ***it wela=P2^7; //bit definitions ***it sclk=P2^4; ***it io=P2^5; ***it rst=P1^1; ***it A0=ACC^0; ***it A7=ACC^7; uc table1[]=" 20-- --/--/---"; //codes uc table2[]=" --:--:-- ---C "; uc table3[]="0123456789"; //uc sec1,sec2,min1,min2,hr1,hr2,date1,date2,mon1,mon2,year1,year2,tem,weekday; uc sec,min,hr,date,mon,year,weekday; void delay(uc x); void display_1602(); void write_com1602(uc com); void write_data1602(uc dat); void initial_1602(); void initial_1302(); void write_byte1302(uc dat); uc read_byte1302(); void write_1302(uc add,uc dat); uc read_1302(uc add); uc bcd_convert(uc bcd); //16-10 void data_processing(); //read data and convert it void main() { initial_1602(); delay(5); initial_1302(); delay(5); while(1) { write_1302(0x8e,0x00); data_processing(); write_1302(0x8e,0x80); delay(5); display_1602(); } } //* 1602 settings**// void initial_1602() { uc a; dula=0; wela=0; write_com1602(0x38); //delay(20); write_com1602(0x0c); //开显示,关光标 // delay(20); write_com1602(0x06); //光标右移,字符不移 // delay(20); write_com1602(0x01); //清屏 delay(20); write_com1602(0x80); a=0; while(table1[a]!=' |