欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: 藍(lán)橋杯 DS1302驅(qū)動程序 [打印本頁]

作者: 15249798685    時間: 2018-4-13 14:06
標(biāo)題: 藍(lán)橋杯 DS1302驅(qū)動程序
/*
  程序說明: DS1302驅(qū)動程序
  軟件環(huán)境: Keil uVision 4.10
  硬件環(huán)境: CT107單片機(jī)綜合實(shí)訓(xùn)平臺 8051,12MHz
  日    期: 2011-8-9
*/

#include <reg52.h>
#include <intrins.h>

sbit SCK=P1^7;               
sbit SDA=P2^3;               
sbit RST = P1^3;   // DS1302復(fù)位                                                                                                

void Write_Ds1302_Byte(unsigned  char temp)
{
        unsigned char i;
        for (i=0;i<8;i++)            
        {
                SCK=0;
                SDA=temp&0x01;
                temp>>=1;
                SCK=1;
        }
}   

void Write_Ds1302( unsigned char address,unsigned char dat )     
{
         RST=0;
        _nop_();
         SCK=0;
        _nop_();
         RST=1;        
           _nop_();  
         Write_Ds1302_Byte(address);        
         Write_Ds1302_Byte(dat);               
         RST=0;
}

unsigned char Read_Ds1302 ( unsigned char address )
{
         unsigned char i,temp=0x00;
         RST=0;
        _nop_();
         SCK=0;
        _nop_();
         RST=1;
        _nop_();
         Write_Ds1302_Byte(address);
         for (i=0;i<8;i++)         
         {               
                SCK=0;
                temp>>=1;        
                 if(SDA)
                 temp|=0x80;        
                 SCK=1;
        }
         RST=0;
        _nop_();
         RST=0;
        SCK=0;
        _nop_();
        SCK=1;
        _nop_();
        SDA=0;
        _nop_();
        SDA=1;
        _nop_();
        return (temp);                        
}






歡迎光臨 (http://m.raoushi.com/bbs/) Powered by Discuz! X3.1