Code:
include "modedefs.bas"
OSCCON = %01110010 'SET INTOSC TO 8MHZ
ANSELC=%00000000
ANSELD=%00000000 'disable ADC
ANSELB=%00000000
ANSELA=%00000000
ANSELE=%00000000
TRISC=%00000000 'set PORTC as output all
TRISD=%00000000 'set PORTD as output all
TRISB=%00000000 'set PORTD as output all
TRISA=%00000110 'tried to make 4-5 pins inputs or outputs, no difference
TRISE=%00000000
DEFINE OSC 8 'OSC SPEED
SDA Var PORTA.5 'DS 3231 pins
SCL Var PORTA.4
RTCYear Var Byte
RTCMonth Var Byte
RTCDate Var Byte
RTCDay Var Byte
RTCHour Var Byte
RTCMin Var Byte
RTCSec Var Byte
RTCCtrl Var Byte
settime:
'rtcsec=0 ' this is necessary to make clock tick
I2CWrite SDA, SCL, $D0, $00, [RTCSec, RTCMin, RTCHour, RTCDay, RTCDate, RTCMonth, RTCYear, RTCCtrl]
Return
gettime:
I2CRead SDA, SCL, $D0, $00, [RTCSec, RTCMin, RTCHour, RTCDay, RTCDate, RTCMonth, RTCYear, RTCCtrl]
Return
if DRO<>rtcmin then 'check for time changes, so display only is refreshed when time is changed
cvlileba=1
else
cvlileba=0
endif
DRO=rtcmin
Return
timedecode: 'decode time from RTC into values suitable for nixie digit illumination
t1=rtchour >> 4 'tens of hours digits
t2=rtchour // 16 'ones of hours
t3=rtcMin >> 4 'tens of minutes
T4=rtcMin // 16 'ones of minutes
return
Bookmarks