Shop OBEX P1 Docs P2 Docs Learn Events
Ds1302 — Parallax Forums

Ds1302

Dave ADave A Posts: 31
edited 2012-08-10 08:48 in BASIC Stamp
I am looking for help on creating an up ramp that will work with the DS1302 for setting time.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-07-25 18:06
    What do you mean by "up ramp"? That could mean all sorts of things. How do you want to make use of the DS1302? It's a Real-Time-Clock.

    You really have to be much more specific about what you want to do if you want any kind of specific help.
  • Dave ADave A Posts: 31
    edited 2012-08-06 16:04
    I am trying to set the time using a minuites button and an hours button. I was using a ramp generator that creats decimal output, but the DS13202 uses hex input. Any suggestions on how to do this.
    Dave
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2012-08-07 09:05
    The DS1302 uses BCD, not Hex to store values. In order to increment the values and have them properly encode, you can use the following code snippets to convert the values from BCD to DEC to manipulate and then from DEC to BCD to send back to the DS1302. Simple change the name counter to the variable you're trying to modify. Use the BCD to DEC routine to before making changes and the DEC to BCD to store those changes back to the DS1302. I hope this helps.
    BCD_Decimal:
      counter = (counter.NIB1 * 10) + counter.NIB0
      RETURN
                                    ' Convert BCD To Decimal
    Decimal_BCD:
      counter = (counter / 10 << 4) + (counter // 10)
      RETURN
    
  • Mike2545Mike2545 Posts: 433
    edited 2012-08-10 08:48
    We talked about this here http://forums.parallax.com/showthread.php?134992-Convert-a-hex-value-to-dec

    I hope you find it useful
Sign In or Register to comment.