📄 dallas1307.asm
字号:
;==============================================================================
; DS1307 - Real Time Clock Interface
;------------------------------------------------------------------------------
; Notes:
;
; This module uses the I2C module functions to exchange information with a
; Dallas 1307 real time clock and RAM chip.
;
; The routines allow multiple contiguous registers to be transferred between
; the PIC and the RTC in a single call.
;==============================================================================
; Revision History:
;
; 2005-02-03 AJ Initial version
;------------------------------------------------------------------------------
include ../pic.inc
include config.inc
errorlevel -302
global DS1307Rx
global DS1307Tx
extern I2C_REGISTER
extern I2C_REGCOUNT
extern I2cStart
extern I2cStop
extern I2cRxByte
extern I2cTxByte
extern I2cAck
extern I2cNack
;==============================================================================
code
;
;
; Words: 24/26 Cycles: 11/13 Stack Depth: 0
DS1307Rx: call I2cStart
movlw h'd0'
call I2cTxByte
call I2cNack
banksel I2C_REGISTER
movf I2C_REGISTER,W
call I2cTxByte
call I2cNack
call I2cStart
movlw h'd1'
call I2cTxByte
call I2cNack
RxLoop call I2cRxByte
movwf INDF
incf FSR,F
banksel I2C_REGCOUNT
decf I2C_REGCOUNT,F
skpnz
goto RxDone
call I2cAck
goto RxLoop
RxDone call I2cNack
goto I2cStop
;
;
DS1307Tx: call I2cStart
movlw h'd0'
call I2cTxByte
call I2cNack
banksel I2C_REGISTER
movf I2C_REGISTER,W
call I2cTxByte
call I2cNack
TxLoop movf INDF,W
incf FSR,F
call I2cTxByte
call I2cNack
banksel I2C_REGCOUNT
decfsz I2C_REGCOUNT,F
goto TxLoop
goto I2cStop
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -