找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 5448|回復: 0
收起左側(cè)

不知道問題出在哪里, 向高手請教

[復制鏈接]
ID:17382 發(fā)表于 2009-9-19 23:54 | 顯示全部樓層 |閱讀模式

由于剛學C語言編程,沒學匯編,對硬件不是太了解。這是用1302編時鐘程序;用Proteus仿真。我不知道問題出在哪里??向高手請教;
郁悶不知道怎么插入圖片。
void main()    
{
 init();  //初始化
 displayda();   //初始化 顯示;
// testdate();
 while(1)
 {
  displayda1();    //液晶顯示;
   keyTimeSet();   //鍵盤掃描;
  a=read_2401add(1);     //  加這句就出錯,液晶顯示不能做到一秒走一步;??????去掉正常;
                                     //讀出2401地址碼1的數(shù)據(jù);
   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);
       }
       }
     }
    }
   }
}


 

回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表