I've tried to adapt the code from basic stamp, but it does not works:
Code:
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
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 1500
DEFINE LCD_DATAUS 44
define OSC 4
DataIO VAR PORTC.2 ' DS1302.6
Clock VAR PORTC.1 ' DS1302.7
CS1302 VAR PORTC.3 ' DS1302.5
WrSecs CON $80 ' Write Seconds
RdSecs CON $81 ' Read Seconds
WrMins CON $82 ' Write Minutes
RdMins CON $83 ' Read Minutes
WrHrs CON $84 ' Write Hours
RdHrs CON $85 ' Read Hours
CWPr CON $8E ' Write Protect Register
WPr1 CON $80 ' Set Write Protect
WPr0 CON $00 ' Clear Write Protect
WrBurst CON $BE ' Write Burst Of Data
RdBurst CON $BF ' Read Burst Of Data
WrRam CON $C0 ' Write RAM Data
RdRam CON $C1 ' Read RAM Data
Hr24 CON 0 ' 24 Hour Mode
Hr12 CON 1 ' 12 Hour Mode
index VAR Byte ' Loop Counter
reg VAR Byte ' Read/Write Address
ioByte VAR Byte ' Data To/From DS1302
secs VAR Byte ' Seconds
mins VAR Byte ' Minutes
hrs VAR Byte ' Hours
date VAR Byte
month VAR Byte
day VAR byte ' Day
year VAR Byte ' Year
ampm VAR hrs.BIT5 ' AM/PM Flag Bit
clockMode VAR hrs.BIT7 ' 12/24 Hour Mode Bit
ampmFlag VAR Bit ' 0 = AM, 1 = PM
modeFlag VAR Bit ' 0 = 24, 1 = 12 (Hours)
work VAR Byte ' Work Data
MAINLOOP:
GOSUB GET_TIME
lcdout $fe,1,"T:",#SECS, " ", #MINS, " ", #HRS, " "
PAUSE 1000
GOTO MAINLOOP
END
Get_Time: ' DS1302 Burst Read
HIGH CS1302 ' Select DS1302
SHIFTOUT DataIO, Clock, LSBFIRST, [RdBurst]
SHIFTIN DataIO, Clock, LSBPRE, [secs, mins, hrs, date, month, day, year]
LOW CS1302 ' Deselect DS1302
RETURN
Displays 0s....
Bookmarks