串行时钟芯片DS1302的原理与使用

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

DS1302HowToUseTheTrickleChargeTimekeepingChipDS1302姚德法*张洪林YAODefaZHANGHongling本文概括介绍了DS1302时钟芯片的特点和基本组成并通过实例详细说明了有关功能的应用DS1302突发模式AbstractInthisarticle,thefeaturesandbasicarchitecturesaredescribed,alsothesampleprogramsaregiven.KeywordsDS1302BurstMode*中国电子科技集团公司第41研究所1DS1302DS1302DALLAS,/31RAMCPUI/O,DS1302,:RES,I/OSCLKDS1302:!31RAM!I/O,!:2.0~5.5V!2.0V,300nA!/RAM:!8DIP!3!TTL(Vcc=5V)!:-40∀~+85∀!DS12022DS13022.1DS1302DS13021,12.2DS1302DS13022DS1302(7)1,0,DS1302;6,0,1RAM;51;(0),0,1图1DS1302管脚图及内部结构图表1DS1302引脚功能表1Vcc22,3X1,X232768Hz4GND5RST6I/O7SCLK8Vcc1图2控制字节的含义2.3DS1302(~RST):,,/;,~RST,,DS1302~RST,,I/O,Vcc#2.0,~RST与9220061,~RST,SCLK2.4DS1302DS1302,SCLK,SCLK(0);,DS1302,SCLK,(0)(7),~RST,SCLK,3图3DS1302的读写时序,RAM2.5DS1302DS130212,7,BCD23DS13023.1DS1302,DS1302RAMDS1302RAM,RAM,31,8,COH~FDH,,;RAM,RAM31,FEH()FFH()4,3,图4DS1302和微控制器通用接口示意图表2DS1302的日历时钟寄存器及其控制字7654321080H81H005982H83H0059084H85H0112002312/24010/AP86H87H0128,29,30,310088H89H01120008AH8BH0107000008CH8DH00993.2DS1302,ATMELMega,3.2.1,DS1302#define-DS1302Send(DDRB|=0x20)/*DS1302*/#define-DS1302Receive(DDRB&=~0x20)/*DS1302*/#define-SendHigh2I-O(PORTB|=0x20)/*DS13021*/#define-SendLow2I-O(PORTB&=~0x20)/*DS13020*/#define-SetSCLKHigh(PORTB|=0x10)/*DS1302SCLK*/#define-SetSCLKLow(PORTB&=~0x10)/*DS1302SCLK*/#define-IsData1Rxd(PINB&0x20)/*1*/#define-RSTH(PORTB|=0x40)/*DS1302RST*/#define-RSTL(PORTB&=~0x40)/*DS1302RST*/3.2.2与2006193/*********************//*:DS1302:Cmd*//*********************/voidSendCmd(ucCmd){uci;-DS1302Send;//-no-operation();//,2M//,bit0for(i=0;i8;i++){if(Cmd&(1i)){-SendHigh2I-O;∃∃∃no-operation();}else{-SendLow2I-O;-no-operation();}-SetSCLKHigh;-no-operation();-no-operation();-SetSCLKLow;}/******************//*:DS1302*//******************/voidRst1302(void){uci;-RSTL;-no-operation();-SetSCLKLow;for(i=0;i8;i++){//SCLKRST1us,[8M]-no-operation();}-RSTH;}/*****************//*:DS1302*//*:DataNum*//*****************/voidRxComT(uc*Buf,ucDataNum){ucucNum,ucBit,ucData;-DS1302Receive;//-no-operation();//,2M//DataNumfor(ucNum=0;ucNumDataNum;ucNum++){ucData=0;//,bit0for(ucBit=0;ucBit8;ucBit++){-SetSCLKLow;//SCLK-no-operation();if(-IsData1Rxd)ucData|=(1ucBit);else∃∃∃no-operation();-SetSCLKHigh;//SCLK}*(Buf+ucNum)=ucData;}}4,5:[1]

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功