Shop OBEX P1 Docs P2 Docs Learn Events
Problem with DS1307_RTCDemo — Parallax Forums

Problem with DS1307_RTCDemo

TimHTimH Posts: 48
edited 2014-02-08 18:26 in Propeller 1
I having problems setting the time of the DS1307.
I have it wired as described with 10K pull ups to 3.3V
The only code I changed was the RX and TX pins and the baud rate (set to 115200)
I get the help menu but however I enter the Time and Date the information is not updated.
I can see clock and data activity between RTC and Prop.
I'm wondering it I have a bad DS1307
Does anyone know the format I need to send to update the Time and Date ?

Thanks

Comments

  • JonnyMacJonnyMac Posts: 9,107
    edited 2014-02-08 15:34
    DS1307 registers are stored in BCD format. I uses these methods in my DS1307 code.
    pub bcd2dec(bcd)
    
      return ((bcd >> 4) * 10) + (bcd & $0F)
    
    
    pub dec2bcd(dec)
    
      return ((dec / 10) << 4) | (dec // 10)
    
  • TimHTimH Posts: 48
    edited 2014-02-08 15:42
    At this point I'm just trying to get the demo program to work.
    The program was on the Obex named DS1307_RTCDemo
    I receive the message to enter the exact time but every format I've entered does not update the RTC
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-02-08 16:00
    If it's the demo Kye wrote, you have to type in "date" first.
    It then prompts for each component of the time and date.
  • TimHTimH Posts: 48
    edited 2014-02-08 16:07
    Duane Degn wrote: »
    If it's the demo Kye wrote, you have to type in "date" first.
    It then prompts for each component of the time and date.
    I think to display the current time you enter "date"
    To change the time you enter "time"
    I do receive the instruction to enter the exact time but however I enter it, the updated date/time is what I suppose is the default "Sunday, December 01, 2000 12:01:48 AM"
    The time does increment but I can never change it.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-02-08 16:56
    You can try my version - it lets you set the clock in 12 or 24 hour mode...

    Note: it is set up to use pin 2 for SDA and pin 1 for SCL.
    The terminal comm is set for 57600
    It waits for you to enter "y" within 5 sec if you want to set the clock and prompts for each date/time component.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-02-08 17:02
    TimH wrote: »
    I think to display the current time you enter "date"
    To change the time you enter "time"
    I do receive the instruction to enter the exact time but however I enter it, the updated date/time is what I suppose is the default "Sunday, December 01, 2000 12:01:48 AM"
    The time does increment but I can never change it.

    You're right about the "time" command.

    My guess is it's a wiring issue. Which Propeller board are you using? The QuickStart's pin positions are opposite one would expect for P28 and P29.
  • TimHTimH Posts: 48
    edited 2014-02-08 17:17
    Duane Degn wrote: »
    You're right about the "time" command.

    My guess is it's a wiring issue. Which Propeller board are you using? The QuickStart's pin positions are opposite one would expect for P28 and P29.
    Using the Professional Dev Board
    I have SDA connected to P29 via a 1K with 10K pull up to 3.3
    SCL to P 28 with 10K pull up.
  • TimHTimH Posts: 48
    edited 2014-02-08 17:22
    You can try my version - it lets you set the clock in 12 or 24 hour mode...

    Note: it is set up to use pin 2 for SDA and pin 1 for SCL.
    The terminal comm is set for 57600
    It waits for you to enter "y" within 5 sec if you want to set the clock and prompts for each date/time component.

    Thanks Ron

    I went thru the time set procedure but get the same result - date and time are zeros.
    I'm starting to think I have a bad DS1307 - I just don't seem to be able to write to it.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-02-08 17:29
    TimH wrote: »
    Thanks Ron

    I went thru the time set procedure but get the same result - date and time are zeros.
    I'm starting to think I have a bad DS1307 - I just don't seem to be able to write to it.

    That is certainly possible. Have you ever gotten that IC to work before?
    Are you using a 3V coin cell for the DS1307?
  • TimHTimH Posts: 48
    edited 2014-02-08 17:43
    That is certainly possible. Have you ever gotten that IC to work before?
    Are you using a 3V coin cell for the DS1307?

    I just re-read the data sheet and found if you don't connect a battery then connect pin 3 to Gnd.
    I thought that was it but same result.
    No - I've never had this chip working - brand new.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-02-08 17:57
    TimH wrote: »
    I just re-read the data sheet and found if you don't connect a battery then connect pin 3 to Gnd.
    I thought that was it but same result.
    No - I've never had this chip working - brand new.

    I prefer of DS3221 chip - more accurate and no external crystal.
    I have this Macetech module and a couple of his earlier version:
    http://macetech.com/store/index.php?main_page=product_info&products_id=8&zenid=4ee70dc779c0e53cf59c5189ee3f9acb

    Good luck!
  • TimHTimH Posts: 48
    edited 2014-02-08 18:03
    OK sorted the problem with the DS1307_RTCDemo method.
    I was sending CR & LF at the end of each parameter - I changed the terminal program to only send CR and now OK
    Ron - Still not got your method working but will keep at it.

    Thanks all
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-02-08 18:22
    TimH wrote: »
    I have SDA connected to P29 via a 1K with 10K pull up to 3.3

    You shouldn't don't need the 1K series resistor. The I2C line is not driven by the DS1307. The line will only transition between 3.3V and 0V (I monitored this with an oscilloscope once to convince myself (with a DS1307 chip)). Some 5V devices that will work with 3.3V logic won't work if there's a resistor in series. It might not be interfering with the data but it's certainly not needed.
  • Ron CzapalaRon Czapala Posts: 2,418
    edited 2014-02-08 18:26
    TimH wrote: »
    OK sorted the problem with the DS1307_RTCDemo method.
    I was sending CR & LF at the end of each parameter - I changed the terminal program to only send CR and now OK
    Ron - Still not got your method working but will keep at it.

    Thanks all

    I'm running a tweaked version of my code now - it displays the date and time on the Parallax 16x2 serial LCD module.
    Not sure why it is not working for you if you changed the pin assignments for your wiring setup...
Sign In or Register to comment.