unit DS3231_U1; interface // global part { $W+} // enable/disable warnings for this unit uses; {--------------------------------------------------------------} { Const Declarations } const {$IDATA} {--------------------------------------------------------------} { Type Declarations } type DS_Record = record DS_Sec : byte; DS_Min : byte; DS_Hour : byte; DS_Day : byte; DS_Date : byte; DS_Months : byte; DS_Year : byte; end; {--------------------------------------------------------------} { Var Declarations } var DSRTC : DS_Record; {--------------------------------------------------------------} { functions } function Get_DsRTC : boolean; function Set_DsRTC : boolean; implementation // local part {--------------------------------------------------------------} { Type Declarations } type {--------------------------------------------------------------} { Const Declarations } const DSAdress : byte = $68; {--------------------------------------------------------------} { Var Declarations } {$IDATA} var {--------------------------------------------------------------} { functions } function Get_DsRTC : boolean; begin DisableInts; if I2Cstat(DSAdress) then I2Cout(DSAdress, $00); I2Cinp(DSAdress, DSRTC); ENABLEINTS($87); return(true); else ENABLEINTS($87); return(false); endif; end; function Set_DsRTC : boolean; begin DisableInts; { DSRTC.DS_Sec:= ByteToBCD(RTCgetSecond); DSRTC.DS_Min:= ByteToBCD(RTCgetMinute); DSRTC.DS_Hour:= ByteToBCD(RTCgetHour); DSRTC.DS_Day:= ByteToBCD(RTCgetWeekDay); DSRTC.DS_Months:= ByteToBCD(RTCgetMonth); DSRTC.DS_Date:= ByteToBCD(RTCgetDay); DSRTC.DS_Year:= ByteToBCD(RTCgetYear); } if I2Cstat(DSAdress) then I2Cout(DSAdress, $00, DSRTC); ENABLEINTS($87); return(true); else ENABLEINTS($87); return(false); endif; end; initialization // at StartUp // finalization // optional // at System_ShutDown end DS3231_U1.