Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
mbyka said:DS1302 AND PBP RTC CODE
'***************************************************
'***** MBYKA **********
'***************************************************
' DS1302 RTC use
Include "MODEDEFS.BAS"
Define LCD_DREG PORTB
Define LCD_DBIT 4
Define LCD_RSREG PORTB
Define LCD_RSBIT 0
Define LCD_EREG PORTB
Define LCD_EBIT 1
'pins
RST var PORTA.0
IO var PORTA.1
SCLK var PORTA.2
'variables
rtcyear var byte
rtcday var byte
rtcmonth var byte
rtcdate var byte
rtchr var byte
rtcmin var byte
rtcsec var byte
rtccontrol var byte
Main:
Low RST ' Reset RTC
Low SCLK
' saat Set 13:42:00 04/13/02
rtcyear = $02
rtcday = $06
rtcmonth = $04
rtcdate = $13
rtchr = $13
rtcmin = $42
rtcsec = $00
Gosub SetTime
Goto Main_Loop
Main_Loop:
Gosub gettime ' saati oku
Lcdout $fe, 1 '1.satır
lcdout hex2 rtcmonth, "/", hex2 rtcdate, "/" , hex2 rtcyear
lcdout $fe,$c0
lcdout hex2 rtchr, ":", hex2 rtcmin, ":", hex2 rtcsec
Pause 300 ' 0.3 saniye bekle
Goto Main_Loop
SetTime:
RST = 1 ' Ready for transfer
' Enable write
Shiftout IO, SCLK, LSBFIRST, [$8e, 0]
RST = 0 ' Reset RTC
RST = 1 ' Ready for transfer
' Write all 8 RTC registers in burst mode
Shiftout IO, SCLK, LSBFIRST, [$be, rtcsec, rtcmin, rtchr, rtcdate, rtcmonth, rtcday, rtcyear, 0]
RST = 0 ' Reset RTC
Return
GetTime: ' Subroutine to read time from RTC
RST = 1 ' Ready for transfer
Shiftout IO, SCLK, LSBFIRST, [$bf] ' Read all 8 RTC registers in burst mode
Shiftin IO, SCLK, LSBPRE, [rtcsec, rtcmin, rtchr, rtcdate, rtcmonth, rtcday, rtcyear, rtccontrol]
RST = 0 ' Reset RTC
Return
End