由于刚学C语言编程,没学汇编,对硬件不是太了解。这是用1302编时钟程序;用Proteus仿真。我不知道问题出在哪里??向高手请教; 郁闷不知道怎么插入图片。 void main() { init(); //初始化 displayda(); //初始化 显示; // testdate(); while(1) { displayda1(); //液晶显示; keyTimeSet(); //键盘扫描; a=read_2401add(1); // 加这句就出错,液晶显示不能做到一秒走一步;??????去掉正常; //读出2401地址码1的数据; k2=!k2; //正常;P1^0口; } } uchar read_2401add(uchar address)//测试过读取正常; { uchar date2401; start(); write_byte(0xa0); respons(); write_byte(address); respons(); start(); write_byte(0xa1); respons(); date2401=read_byte(); stop(); return date2401; }
void displayda1() 液晶显示;
{ second = read1302(0x80); timestring[6] = (second&0xf0)>>4; timestring[7] = second&0x0f; lcddisplay_com(0x80+0x4b); lcddisplay_date(timestring[6]+0x30); lcddisplay_date(timestring[7]+0x30); if(second==0) { minute = read1302(0x82); timestring[3] = (minute&0xf0)>>4; timestring[4] = minute&0x0f; lcddisplay_com(0x80+0x48); lcddisplay_date(timestring[3]+0x30); lcddisplay_date(timestring[4]+0x30); if(minute==0) { hour = read1302(0x84); timestring[0] = (hour&0xf0)>>4; timestring[1] = hour&0x0f; lcddisplay_com(0x80+0x45); lcddisplay_date(timestring[0]+0x30); lcddisplay_date(timestring[1]+0x30); if(hour==0) { day = read1302(0x86); week = read1302(0x8a); datestring[6] = (day&0xf0)>>4; datestring[7] = day&0x0f; lcddisplay_com(0x80+0x0a); lcddisplay_date(datestring[6]+0x30); lcddisplay_date(datestring[7]+0x30); lcddisplay_com(0x80+0x09+0x04); week=week&0x07; displayweek(week); if(day==1) { month = read1302(0x88); datestring[3] = (month&0xf0)>>4; datestring[4] = month&0x0f; lcddisplay_com(0x80+0x07); lcddisplay_date(datestring[3]+0x30); lcddisplay_date(datestring[4]+0x30); if(month==1) { year = read1302(0x8c); datestring[0] = (year&0xf0)>>4; datestring[1] = year&0x0f; lcddisplay_com(0x80+0x04); lcddisplay_date(datestring[0]+0x30); lcddisplay_date(datestring[1]+0x30); } } } } } }
|