找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 4793|回复: 0
打印 上一主题 下一主题
收起左侧

不知道问题出在哪里, 向高手请教

[复制链接]
跳转到指定楼层
楼主
ID:17382 发表于 2009-9-19 23:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

由于刚学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);
       }
       }
     }
    }
   }
}


 

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表