November 21, 2024, 05:54:27 PM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


DS1302 RAM Mode Routine

Started by samsam, March 13, 2008, 09:45:55 PM

Previous topic - Next topic

samsam

March 13, 2008, 09:45:55 PM Last Edit: March 13, 2008, 09:54:50 PM by samsam
What I want to learn how to do is write and save to the DS1302 RAM and then recall what was saved and use it latter not using the computer key board but writing it Basic Stamp Code

This only an example this want to save and then recall

counter = counter + 1     I want to write to the ram results then  recall the saved RAM results latter and use it


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
Sam

I Want  Thank You for All Of Your Time And Help

...............In Helping Getting Thing To Work........

JonnyMac

March 13, 2008, 11:20:42 PM #1 Last Edit: March 13, 2008, 11:34:49 PM by JonnyMac
Out of curiosity, how are you connecting the DS1302 to your Prop-2?

Here are a couple of my old Nuts & Volts articles that will help:
  -- http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol1/col/nv33.pdf
  -- http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/vol1/col/nv34.pdf
Jon McPhalen
EFX-TEK Hollywood Office