Shop OBEX P1 Docs P2 Docs Learn Events
need help with pins for the DS1302 chip — Parallax Forums

need help with pins for the DS1302 chip

lockadoclockadoc Posts: 115
edited 2010-03-15 04:40 in Propeller 1
This will be the first time I'll be using this chip.
I want to use the object DS1302_full.spin from the object exchange. I need to know if my pin setup is correct.
·
This code is from the object
········· PUB init( inClk, inIo, inCe )
········ clkcycles_us := ( clkfreq / _1us· ) #> 381· ' will work better with Propeller II
·
··········· clk := inClk
··········· io· := inIo
··········· ce· := inCe

··········· dira[noparse][[/noparse]ce]~~·········· 'set to output
··········· outa[noparse][[/noparse]ce]~···········
··········· delay_us(2)··········
··········· dira[noparse][[/noparse]clk]~~
··········· outa[noparse][[/noparse]clk]~··········
·



Is this the correct way to set it for my pin useage of·== Pin 9 Clock, Pin 10 Data Enable, Pin 11 Chip enable ==··


PUB init( inClk, inIo, inCe )
· clkcycles_us := ( clkfreq / _1us· ) #> 381· ' will work better with Propeller II

··9·· ·:= inClk
··10· := inIo
··11· := inCe
· dira[noparse][[/noparse]ce]~~·········· 'set to output
· outa[noparse][[/noparse]ce]~···········
· delay_us(2)··········
· dira[noparse][[/noparse]clk]~~
· outa[noparse][[/noparse]clk]~··········
·

When I run it with this setup All I get in the PST is all Zeros·· 00:00:00 00 00 00 00· it refreshes about ever second but does no change.

·

Thanks

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Life is fun with a Prop.



BillS
··· Louisville KY.

Post Edited (lockadoc) : 3/11/2010 5:41:30 AM GMT

Comments

  • Chip CoxChip Cox Posts: 73
    edited 2010-03-11 15:20
    I'm working with the same thing today.

    Using the chip diagram at the top of DS1302_full.spin I did the following

    clk -> pin 0
    io -> pin 1
    ce 1k resistor to pin 2

    my init string is as follows
    rtc.init(0,1,2)

    Are you running it from a cog??· I had something similar happen when I tried to run it from a cog.· I had to initialize and config it inside the cog too.· Here is my adjustment to the included sample code to try it with a cog.

    Hope this helps.
  • lockadoclockadoc Posts: 115
    edited 2010-03-11 18:02
    Thanks for the input, I changed your pins from 0,1,2 to 9,10,11 in the two locations but still I get the same result. Any Ideas?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is fun with a Prop.



    BillS
    ··· Louisville KY.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-03-11 18:31
    lockadoc,
    You have to either use the "code" tags ([noparse][[/noparse] code ] and [noparse][[/noparse] /code ] without the extra spaces) or attach your actual source code to a message using the Attachment Manager (use the Post Reply button to get it).

    What you posted can't possibly work as you've shown it and we need to see what you're actually using to advise you.
  • lockadoclockadoc Posts: 115
    edited 2010-03-11 19:03
    Ok
    using the included object, this is what I get on the PST


    MSG Initiallizing
    Trickle charge resister contents = 00000000
    Writing Ram Address 0 CMD Byte 11000000

    ··· All the way to
    Writing Ram Address 30 CMD Byte 11111100
    ··· Than
    Reading Ram Adress 0 =0
    ··· To
    Reading Ram Adress 30 = 30

    Writing Ram Data in Burst Mode

    Reading Ram Data in Burst Mode
    Data 0 =0
    ·· To
    Data 11 = 0

    THAN ALL GET IS
    00:00:00, 00 00 00 00
    REPEATED UNTIL I STOP THE PST

    This makes me think the chip is working, but not sending the time infromation

    Thanks for· the help setting me back on course.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is fun with a Prop.



    BillS
    ··· Louisville KY.
  • Chip CoxChip Cox Posts: 73
    edited 2010-03-12 02:54
    I change your pins back to what my pins are set to tried it.· It worked fine.· Check and make sure your pins are plugged into the correct pins on the chip.· I found it very confusing.· Some of the documentation out there on this seems to contradict the other documentation.

    Writing RAM address 30 cmd byte = 11111100


    Reading RAM address 0 = 0
    Reading RAM address 1 = 1
    Reading RAM address 2 = 2
    Reading RAM address 3 = 3
    Reading RAM address 4 = 4
    Reading RAM address 5 = 5
    Reading RAM address 6 = 6
    Reading RAM address 7 = 7
    Reading RAM address 8 = 8
    Reading RAM address 9 = 9
    Reading RAM address 10 = 10
    Reading RAM address 11 = 11
    Reading RAM address 12 = 12
    Reading RAM address 13 = 13
    Reading RAM address 14 = 14
    Reading RAM address 15 = 15
    Reading RAM address 16 = 16
    Reading RAM address 17 = 17
    Reading RAM address 18 = 18
    Reading RAM address 19 = 19
    Reading RAM address 20 = 20
    Reading RAM address 21 = 21
    Reading RAM address 22 = 22
    Reading RAM address 23 = 23
    Reading RAM address 24 = 24
    Reading RAM address 25 = 25
    Reading RAM address 26 = 26
    Reading RAM address 27 = 27
    Reading RAM address 28 = 28
    Reading RAM address 29 = 29
    Reading RAM address 30 = 30


    Writing RAM data in burst mode

    Reading RAM data in burst mode
    Data 0 = 30
    Data 1 = 29
    Data 2 = 28
    Data 3 = 27
    Data 4 = 26
    Data 5 = 25
    Data 6 = 24
    Data 7 = 23
    Data 8 = 22
    Data 9 = 21
    Data 10 = 20
    Data 11 = 19


    20:20:00, 03 09 22 09
    20:20:01, 03 09 22 09
    20:20:02, 03 09 22 09
    20:20:03, 03 09 22 09
    20:20:04, 03 09 22 09
    20:20:05, 03 09 22 09
    20:20:06, 03 09 22 09
    20:20:07, 03 09 22 09
    20:20:08, 03 09 22 09
    20:20:09, 03 09 22 09
  • AmaralAmaral Posts: 176
    edited 2010-03-12 13:18
    Are you using Pull up resistor in the SDA and CLK lines ?
  • lockadoclockadoc Posts: 115
    edited 2010-03-12 14:27
    No just a 1K on the enable pin, do i need to use same size on the other pins?



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is fun with a Prop.



    BillS
    ··· Louisville KY.

    Post Edited (lockadoc) : 3/13/2010 7:38:40 AM GMT
  • lockadoclockadoc Posts: 115
    edited 2010-03-13 07:37
    I added two more 1k resistors, now have one on all three lines SCLK,I/O,RST.

    I even changed the pins out from

    ·rtc.init( 11, 9,10 )
    ··· to

    ·rtc.init( 10, 9,11 )

    and I still get the same result.·

    I used a proto board and used a 8 pin dip socket and placed the crystal into the holes next to the dip and bent them over to the dip pins and soldered them together on the bottom of the board.Am I using the right size resistor?



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is fun with a Prop.



    BillS
    ··· Louisville KY.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-13 09:26
    It sounds like you are using series resistors, is that right? If you operate the 1302 directly from 3.3V you can just interface directly with this device. If you do have a resistor you just might need a small "just in case" current limit in the Prop's data line to the RTC's I/O pin. Your description is vague and ambiguous (resistors have two connections, where does each go).

    Make sure you init with the correct pins
    rtc.init(SCLK,I/O,/RST) ' where the pin names here correspond to the datasheet.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • lockadoclockadoc Posts: 115
    edited 2010-03-13 20:45
    I'm Still having No LUCK with this chip,I've removed all the resistors that I installed between the
    (SCLK- PIN 9) ,(I/O -PIN 10) ,(RST-PIN 11) and connected the pins as follows

    rtc.init(SCLK,I/O,RST) = = rtc.nit (9,10,11)

    Is it possible I over heated the cystal while soldering it?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is fun with a Prop.



    BillS
    ··· Louisville KY.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-13 22:28
    Even if your crystal were faulty the SPI access and RAM operates independently from the crystal. I have checked your software and all looks in order. Since you have soldered this on some sort of board then maybe a photo (top and bottom) would be helpful?

    BTW, I noticed after a quick google that there are examples out there with pullup resistors on all three SPI pins, that's funny because the chip itself has 40K pull-downs on all three pins. Just shows people hook up things willy-nilly at times and while you can trust Google to dig it all up you can't trust what you find.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • lockadoclockadoc Posts: 115
    edited 2010-03-14 05:02
    Ok here are two pics
    I've add some other parts for the board which are not part of the clock chip for other objects and they work


    ·AND THANKS FOR THE INTEREST I just can not·think of why I can't get it to work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is fun with a Prop.



    BillS
    ··· Louisville KY.

    Post Edited (lockadoc) : 3/14/2010 5:07:45 AM GMT
    3264 x 2448 - 824K
    1836 x 1378 - 382K
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-15 01:09
    Sorry I missed your post and also that you are still having trouble, just looking at it now. It's a pity you can't use wire-wrapping wire, being fine and single strand makes it infinitely easier to do these kind of things, but your wiring looks neat nonetheless.

    I know it's dumb but since I can't see Pin 1 connected I would ask if it is. Always do a continuity and shorting check as well as the volts on all pins (even gnd) too when it's powered up. Sometimes we are surprised by what is revealed. That also means we cross check our test equipment by checking against other things we do know are right (gee, I thought I was connected to the ground!)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • lockadoclockadoc Posts: 115
    edited 2010-03-15 02:55
    Pin 1 from the DS1302 goes to the +5 volt rail, I guess I should change it to 3 volts?

    The reason I'm trying to use the DS1302 chip is I'm thinking of using it instead of the realtime clock object JM_SOFTRTC from the object exchange. for the project I posted in completed projects.

    Thanks for trying to help see where I'm going wrong.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is fun with a Prop.



    BillS
    ··· Louisville KY.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-03-15 04:06
    Even at a 5V supply the minimum logic input threshold (Vih) is 2.4V so there should be no problem there. As long as the write protect is cleared by the software you should be able to talk to it and as long as another cog hasn't tried to take over the same pins. I assume the code you posted is what you actually used with nothing else. Can you scope it? Even a meter check should tell you something.

    I just hope you have a genuine chip as it is not not uncommon to be sold a fake one although it's a long shot (shoot it, now there's a solution).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • lockadoclockadoc Posts: 115
    edited 2010-03-15 04:40
    Yes the only code that was uploaded to the prop was the one I posted . as far as the supplier of the chip goes I trust them completely (Parallax). Think I'll try another chip on different ProtBoard, using the pins that are the default pins from the object.

    Stay Tuned for the results later on Monday



    Thanks BillyS

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is fun with a Prop.



    BillS
    ··· Louisville KY.
Sign In or Register to comment.