找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 1456|回復(fù): 1
收起左側(cè)

基于51單片機(jī)制作的電子時(shí)鐘無(wú)法仿真模擬!新人求助

[復(fù)制鏈接]
ID:343840 發(fā)表于 2018-6-3 10:01 | 顯示全部樓層 |閱讀模式
源代碼:
# include <reg51.h>
# define uchar unsigned char
# define uint unsigned int
uchar code write_address[]={0x80,0x82,0x84,0x86,0x88,0x8a,0x8c};
uchar code read_address[]={0x81,0x83,0x85,0x87,0x89,0x8b,0x8d};
uchar code table[]={0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xf6};
uchar date[]={0x01,0x01,0x01,0x09,0x05,0x02,0x12};
uchar date1[]={0x01,0x01,0x01,0x09,0x05,0x02,0x12};
sbit RST=P3^0;
sbit SCL=P3^1;
sbit SDA=P3^2;
sbit ACC7=ACC^7;
uchar temp,byte;
int write_byte(int adderss);
void delay(uint m)
   {
      while(m--);
   }
void wirte_byte(uchar byte)
   {
      uchar m;
      for(m=0;m<8;m++)
      {
  byte>>=1;
  SCL=0;
  SDA=CY;
  SCL=1;
      }
   }

uchar read_byte(void)
{
  uchar m;
  for(m=0;m,8;m++)
   {
    ACC=ACC>>1;
    ACC7=SDA;
    SCL=1;
    SCL=0;
   }
  return (ACC);
}  
   
void write_1302(uchar address,uchar date)
   {
      RST=0;
      SCL=0;
      RST=1;
      write_byte(address);
      write_byte(date);
      RST=0;
   }
read_data(uchar address)
   {
      uchar temp;
      RST=0;
      SCL=0;
      RST=1;
      write_byte(address|0x01);
      temp=read_byte();
      SCL=1;
      RST=0;
      return(temp);
   }
   
void read_time()
   {
      uchar m,temp3,temp1,temp2;
      temp3=0x80;
      for(m=0;m<7;m++)
  {
     temp1=read_data(temp3);
     temp2=temp1;
     date[m]=(temp1>>1)&0x0f;
     date1[m]=(temp2>>5)&0x07;
     temp3=temp3+0x02;
  }
   }
void set_RTC(void)
   {
      uchar m;
      write_1302(0x8E,0x00);
      for(m=0;m<7;m++)
  {
     write_1302(write_address[m],date[m]);
  }
      write_1302(0x8E,0x00);
   }
void main(void)
   {
      RST=0;
      set_RTC();
      while(1)
  {
     read_time();
     P2=0xfe;
     P1=table[date[0]%10];
     delay(500);
     P2=0xfd;
     P1=table[date1[0]%10];
     delay(500);
     P2=0xfb;
     P1=0x02;
     delay(500);
     P2=0xf7;
     P1=table[date[1]%10];
     delay(500);
     P2=0xef;
     P1=table[date1[1]%100];
     delay(500);
     P2=0xdf;
     P1=0x02;
     delay(500);
     P2=0xbf;
     P1=table[date[2]%10];
     delay(500);
     P2=0x7f;
     P1=table[date1[2]%10];
     delay(500);
  }
}
附電路圖。
代碼檢查無(wú)錯(cuò)誤,電器規(guī)則性檢查無(wú)錯(cuò)誤,但是模擬時(shí)無(wú)任何反應(yīng)。。。。。
求問(wèn)大佬們,這是什么情況,怎么解決?


TIM截圖20180603095658.png
回復(fù)

使用道具 舉報(bào)

ID:343840 發(fā)表于 2018-6-3 10:03 | 顯示全部樓層
剛剛接觸單片機(jī),希望大佬幫助問(wèn)一下,
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表