日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當前位置:首頁 > 單片機 > 單片機
[導讀] ;*********************************************************************; Revision History:;*********************************************************************;---------- 管腳定義 ------

 

;*********************************************************************
; Revision History:
;*********************************************************************

;---------- 管腳定義 --------------

RST EQU P1.5 ;DS1302
IO EQU P1.6
SCLK EQU P1.7


;*******************************************************************************
; The following is about DS1302
;*******************************************************************************

;-------------------------------------------------------------------------------
; RST1302 Reset 1302
; Function: Sends the command to reset 1302
; Calls: None
; InPara: None
; OutPara: None
; Register Usage: None
;-------------------------------------------------------------------------------
RST1302:clr sclk
clr rst
setb rst
ret

;-------------------------------------------------------------------------------
; WRBYTE Write a byte to 1302
; Function: Shifts out a byte, starting with the LSB, to the RAM
; Calls: None
; InPara: A = the byte to be sent
; OutPara: None
; Register Usage: R2
;-------------------------------------------------------------------------------
WRBYTE: mov r2,#08
wrbyt1: rrc a
mov io,C
clr sclk
setb sclk
djnz r2,wrbyt1
ret

;-------------------------------------------------------------------------------
; RDBYTE Read a byte from 1302
; Function: Recieves a byte, LSB first, from the RAM
; Calls: None
; InPara: None
; OutPara: A = recieved byte
; Register Usage: R2
;-------------------------------------------------------------------------------
RDBYTE: mov R2, #08 ; Set bit counter to eight
clr a
setb io
rdbyt1: setb sclk ; BringSCKhigh
clr sclk ; Bring SCK low
mov C, io ; Receive data bit and store in carry
rrc A ; Shift byte right through carry
djnz R2, rdbyt1 ; Finish if last data bit
ret

;-------------------------------------------------------------------------------------------------
; GETTIME Get time from 1302
; Function:
; Calls: wrbyte,rdbyte
; InPara: R0 = Last address to store time
; OutPara: None
; Register Usage: R0,A
;-------------------------------------------------------------------------------------------------
gettime:lcall rst1302
mov a,#0bfh
lcall wrbyte ;cLOCk burst read (eight registers)
lcall rdbyte ;sec
mov @r0,a
dec r0
lcall rdbyte ;min
mov @r0,a
dec r0
lcall rdbyte ;hour
mov @r0,a
dec r0
lcall rdbyte ;date
mov @r0,a
dec r0
lcall rdbyte ;month
mov @r0,a
dec r0
lcall rdbyte ;day
mov @r0,a
dec r0
lcall rdbyte ;year
mov @r0,a
dec r0
lcall rdbyte ;must read control register in burst mode
lcall rst1302
clr rst
ret

;-------------------------------------------------------------------------------------------------
; SETTIME Set time to 1302
; Function:
; Calls: wrbyte,rdbyte
; InPara: R0 = Last address of the time to be sent
; OutPara: None
; Register Usage: R0,A
;-------------------------------------------------------------------------------------------------
settime:lcall rst1302
mov a,#8eh
lcall wrbyte ;control register
clr a
lcall wrbyte ;dISAble write protect

lcall rst1302
mov a,#90h
lcall wrbyte ;trICkle charger register
mov a,#0abh
lcall wrbyte ;enable, 2 diodes, 8K resistor

lcall rst1302
mov a,#0beh
lcall wrbyte ;clock burst write (eight registers)

mov a,@r0
dec r0
lcall wrbyte ;sec
mov a,@r0
dec r0
lcall wrbyte ;min
mov a,@r0
dec r0
lcall wrbyte ;hour
mov a,@r0
dec r0
lcall wrbyte ;date
mov a,@r0
dec r0
lcall wrbyte ;mon
mov a,@r0
dec r0
lcall wrbyte ;day
mov a,@r0
dec r0
lcall wrbyte ;year

mov a,#80h
lcall wrbyte ;must write control register in burst mode, enable write protect
lcall rst1302
clr rst
ret

;*******************************************************************************

 

 

本站聲明: 本文章由作者或相關機構授權發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內容真實性等。需要轉載請聯系該專欄作者,如若文章內容侵犯您的權益,請及時聯系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關閉