Shop OBEX P1 Docs P2 Docs Learn Events
Complete Spin Code for DS1302 RTC — Parallax Forums

Complete Spin Code for DS1302 RTC

SELSEL Posts: 80
edited 2010-11-01 19:07 in Propeller 1
This all started when I reported that the DS1302 was gaining time.
Well, the problem turn out to be the crystal Parallax sent me. They got a wrong order from their supplier.
The CL on those crystals was not 6pf.

Chris S. gave us a Digi-Key Part Number and I ordered the correct crystal from them and all is WELL! (Part Num: SER3205-ND)
The discussion we all had lead to some great coding and I wish to share my project with you.
The code has been tested and it's good to go!

Many thanks to BR, Chris and Beau.

Enjoy the attached code file.

SEL

Comments

  • magdropmagdrop Posts: 13
    edited 2010-07-20 00:27
    Are these files password protected or has my unzipper gone berserk again?
  • SELSEL Posts: 80
    edited 2010-07-20 01:55
    The zip file was created by Propeller tools. I tested it before posting and it opened up just fine.
    I suspect it is on your end. I just clicked on the link below and opened it up. It seems to be alright.

    SEL
  • BRBR Posts: 92
    edited 2010-07-20 02:06
    @magdrop: you may have to add a ".zip" extension to the file to get it to open...I did.

    @SEL: glad this worked out for you. I learned a few things in the process, too. Good stuff.

    @anyoneInterested: if you're following along at home, here's the genesis of this thread:
    DS1302 learnings
    LCD menu system learnings
  • SELSEL Posts: 80
    edited 2010-07-20 02:27
    BR,

    I am glad you liked the code. You are a big part of it!!

    SEL
  • scurrierscurrier Posts: 32
    edited 2010-10-26 22:53
    Thanks for posting your code. I am studying it because I want to try to make a basic clock.

    I thought that I would need to learn assembly to interface serially with the DS1302 because of timing. From looking at your code, it looks like the exact timing isn't really important? You simply modulate the clock signal when you are ready to send or receive a bit, and you can do that at any speed? Or even a speed that isn't deterministic and changes during communication? Am I right about this?

    Also, I notice you do something like this:
    outa[x] := %01010101

    What would pin x's output state be in this case? 0 or 1? Looks like it would be 1 if I am reading the intention of your code correctly. This isn't documented in the propeller manual but it seems pretty useful in cases similar to how you used it... for using a repeat loop to send a single bit out of a byte and them moving on to the next one.

    Thanks,
    Shaun
  • scurrierscurrier Posts: 32
    edited 2010-11-01 19:07
    To follow up on my own questions in the post above:

    Am I right about this?
    Yes. I wrote my own driver for the DS1302 and the timing is sloppy but it still works. I believe that I stayed within the specs on the data sheet.

    What would pin x's output state be in this case? 0 or 1?
    I stopped being lazy and tested this. The answer is 1.

    -Shaun
Sign In or Register to comment.