中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 自制51單片機超大數(shù)碼管時鐘

        自制51單片機超大數(shù)碼管時鐘

        作者: 時間:2012-08-04 來源:網(wǎng)絡(luò) 收藏

        delay()
        {
        int j;
        for (j=0;j100;j++);
        }

        void display(unsigned char *lp)//顯示
        {
        uint k;
        for (k=0;k4;k++)
        {
        pos=w[k];
        segs=d[lp[k]];
        delay();
        segs=d[17];
        }

        pos=w[4];
        segs=d[flash]; //秒閃爍燈
        delay();
        segs=d[17];

        }

        void Write_Ds1302_Byte(unsigned char temp)
        {
        unsigned char i;
        for (i=0;i8;i++) //循環(huán)8次 寫入數(shù)據(jù)
        {
        SCL2=0;
        SDA2=temp0x01; //每次傳輸?shù)妥止?jié)
        temp>>=1; //右移一位
        SCL2=1;
        }
        }

        /***********************************************************

        *****************/
        void Write_Ds1302( unsigned char address,unsigned char dat )
        {
        RST=0;
        _nop_();
        SCL2=0;
        _nop_();
        RST=1;
        _nop_(); //啟動
        Write_Ds1302_Byte(address); //發(fā)送地址
        Write_Ds1302_Byte(dat); //發(fā)送數(shù)據(jù)
        RST=0; //恢復(fù)
        }
        /*********************************************************

        *******************/
        unsigned char Read_Ds1302 ( unsigned char address )
        {
        unsigned char i,temp=0x00;
        RST=0;
        _nop_();
        SCL2=0;
        _nop_();
        RST=1;
        _nop_();
        Write_Ds1302_Byte(address);
        for (i=0;i8;i++) //循環(huán)8次 讀取數(shù)據(jù)
        {
        if(SDA2)
        temp|=0x80; //每次傳輸?shù)妥止?jié)
        SCL2=0;
        temp>>=1; //右移一位
        SCL2=1;
        }
        RST=0;
        _nop_(); //以下為DS1302復(fù)位的穩(wěn)定時間
        RST=0;
        SCL2=0;
        _nop_();
        SCL2=1;
        _nop_();
        SDA2=0;
        _nop_();
        SDA2=1;
        _nop_();
        return (temp); //返回
        }
        /**************************************************************

        **************/
        void Read_RTC(void) //讀取 日歷
        {
        unsigned char i,*p;
        p=read_rtc_address; //地址傳遞
        for(i=0;i7;i++) //分7次讀取 年月日時分秒星期
        {
        now[i]=Read_Ds1302(*p);
        p++;
        }
        }
        /***********************************************************

        ************/
        void Set_RTC(void) //設(shè)定 日歷
        {
        unsigned char i,*p,tmp;
        for(i=0;i7;i++){
        tmp=now[i]/10;
        now[i]=now[i]%10;
        now[i]=now[i]+tmp*16;
        }
        Write_Ds1302(0x8E,0X00);

        p=write_rtc_address; //傳地址
        for(i=0;i7;i++) //7次寫入 年月日時分秒星期
        {
        Write_Ds1302(*p,now[i]);
        p++;
        }
        Write_Ds1302(0x8E,0x80);
        }

        void keydelay(unsigned char t)
        {
        unsigned char i,j;
        for(i=0;it;i++)
        for(j=0;j120;j++);
        }

        51單片機相關(guān)文章:51單片機教程



        上一頁 1 2 下一頁

        關(guān)鍵詞: 51單片機 超大數(shù)碼管時鐘

        評論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉