Shop OBEX P1 Docs P2 Docs Learn Events
DS1302 RAM Locations — Parallax Forums

DS1302 RAM Locations

hmlittle59hmlittle59 Posts: 404
edited 2008-12-07 21:10 in General Discussion
Hello all,

I'm learning to Write/Read to the Ram locations of the DS1302. But I have a noticed that on (Reset/removal of pwer) that my values some time stay in place. I've let it sit for 10mins. and on power up the value still seem to be there. Does the RAM locations some times retain there previous values or on power up does it always reset to a know state(00,11,*,...etc)? thanks

Seconds Location appears to always be $80 when NOT programed. This is how I know to load my default times, I'm not sure about the RAM Locations??

1) Does the DS1302 have a constant power up state?
2) Does it some times retain values in RAM?

thanks again

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

hmlittle59

Comments

  • MSDTechMSDTech Posts: 342
    edited 2008-12-05 03:31
    Did you attach a supercap or battery to the DS1302 to keep the clock running during power loss? This will also keep the values in ram active.
  • hmlittle59hmlittle59 Posts: 404
    edited 2008-12-05 23:43
    I already have my own board built with a Battery attached, I'm trying to learn about how to program the read and write locations and what to expect on power up(consistently) from the empty cells.

    thanks again

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59
  • MSDTechMSDTech Posts: 342
    edited 2008-12-06 14:47
    I have found that if you lose all power to a DS1302, all the ram will contain 0's. However, if you have a backup battery attached to allow the clock to keep time when power is removed then the DS1302 will also retain whatever values were stored in the ram.
    On our schools weather station, I use this feature to remember which memory location was last used in the EEPROM that stores the logged data. I have two NiMH AA cells on the secondary power pin that keep the clock and ram active during the frequent power drops we experience at the school. I also use the ram to accumulate the data prior to writing to the EEPROM. This allows me to capture the data that was read before the system lost power.
    I've posted the code at http://forums.parallax.com/forums/default.aspx?f=21&m=265354
  • hmlittle59hmlittle59 Posts: 404
    edited 2008-12-07 04:24
    I've got my test program working pretty good now and have found some consistency with (power removed for short periods of time and power removed and pins shorted to ensure to reset). I have yet to get all zeros, got 42,00,00,4,00 a number of times and all different random numbers after the pins are shorted. I think that I have some new DS1302 chips and will plug them in and modify my test code to by-pass my default setting and go straight to the read routine and see what I get. After I finish my testing maybe I'll clean up this code and POST it to show how I did it. I enjoy documenting my code so it will be very easy follow and use.

    1) DS1302 running....Yes/NO
    2) Load Default times if NO
    3) start DS1302
    4) Check AUTO-CONFIG....ON/OFF
    5) Load previous saved defaults if not first time running of DS1302 and AUTO-Config. is ON
    6) Start Pass...Main Menu if from a reset
    7) Also Remember to set a flag when returning to Bank0 to by-pass start-up chks.
    8) Write 2 Separate set of 8 values to DS1302 memory
    9) Read same set of values and display to Debug screen.....

    I will add the BackLight LCDscreen also. Then make any corrections that ya'll suggest that I over looked.

    thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59
  • Mike GreenMike Green Posts: 23,101
    edited 2008-12-07 04:42
    The RAM in the DS1302 takes very little power and works down to quite low voltages (minimum 2.0V). Since the RAM is designed to maintain its contents at 2V, I'm sure it will function for a while below that. Some bits will hold their content longer than others. Eventually, the on-chip voltage will drop to zero. There may be some charges in some of the RAM bits that will bias what state they start with if the power is restored immediately. Eventually, even that will dissipate.

    What state the cells start with after remaining unpowered for some time probably depends partly on small manufacturing variations in cell geometry unless the RAM is actually designed to start in a particular state (like zeros). Beau would have a better idea how these things work.
  • hmlittle59hmlittle59 Posts: 404
    edited 2008-12-07 06:44
    thanks Mike, I hope he'll reply also.

    thanks again

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I HAVE LEARN SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-12-07 21:10
    As a note...in the DS1302 Demo Code there are subroutines for reading and writing to the RAM that require only an address and value for a write and only an address for a read (returning the value).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
Sign In or Register to comment.