Shop OBEX P1 Docs P2 Docs Learn Events
How do you save data in more than one slot in the DS1302 time chip Example given ..> — Parallax Forums

How do you save data in more than one slot in the DS1302 time chip Example given ..>

sam_sam_samsam_sam_sam Posts: 2,286
edited 2011-04-08 11:44 in General Discussion
How would put the next event in the next memery slot and know when the memery slots were full ?

I know how to put Data each memery slot with the VAR WORD

I want to put more than one Event_seconds in memery

Is there a way to this with out doing that way
WriteRam:                                        ' Routine to Save Data to a DS1302 Time Chip
  reg = $FE                                        ' Send Command
  HIGH Timer
  SHIFTOUT DataIO, Clock,LSBFIRST, [reg]
  SHIFTOUT DataIO, Clock, LSBFIRST, [Total_Secs.HIGHBYTE,Total_Secs.LOWBYTE,Event_Secs.HIGHBYTE,Event_Secs.LOWBYTE]
  LOW Timer
  RETURN
 
 
  ReadRam :                           'Routine to Read Data from DS1302 Time Chip
  reg = $FF
  HIGH Timer
  SHIFTOUT DataIO, Clock, LSBFIRST, [reg]
  SHIFTIN DataIO, Clock, LSBPRE, [ Total_Secs.HIGHBYTE,Total_Secs.LOWBYTE,Event_Secs.HIGHBYTE,Event_Secs.LOWBYTE]
  LOW Timer
  DEBUG HOME, "TotalSecs = ",DEC5  Total_Secs,"  Event_Secs = ",DEC5  Event_Secs , CR,                          
 
  RETURN

I can get this to work how ever I do not want to use a computer to use this I want the Basic Stamp to save the even which i can not get this to work

RAM_Mode:
  DO
    DEBUG CLS, "Enter an address from 0-30 (>31 Exits):", CR
    DEBUGIN DEC2 index                  ' Address in DS1302 RAM
    IF index > 30 THEN EXIT             ' Exit if out of range
    DEBUG CRSRXY, 0, 1, "Enter # from 0-255 to store at ", DEC index, CR
    DEBUGIN DEC3 ioByte                 ' Value to store in DS1302 RAM
    DEBUG CRSRXY, 0, 2, "Storing ", DEC ioByte, " at ", DEC index, CR
'
' The address to store data in the DS1302 RAM is obtained by OR-ing
' the command byte with the address shifted left one bit. This is
' because the command byte uses BIT0, BIT6 and BIT7. The address
' occupies BIT1 through BIT5. You are effectively putting the address
' in BIT1-BIT5 of reg.
' Write RAM command = 11xxxxx0 (Uses 3 bits)
' Read RAM command = 11xxxxx1 (Uses 3 bits)
' xxxxx = address (Uses 5 bits)
 
 
reg = WrRam | (index << 1) ' RAM Write Mode + Address
GOSUB RTC_Out ' Send reg + ioByte
ioByte = 0 ' Clear Data Variable
 
 
reg = RdRam | (index << 1) ' RAM Read Mode + Address
GOSUB RTC_In ' Get Data From Address
 
DEBUG CRSRXY, 0, 3, "Address ", DEC index, " contains ", DEC ioByte, CR
DEBUG CRSRXY, 0, 4, "Press ENTER.", CR
DEBUGIN work
LOOP
RETURN
Sign In or Register to comment.