DS1302 Problem, again :(


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

    Default Re: DS1302 Problem, again :(

    Will try it later.

    I also have DS1307, but I can't get it work, even with Basic Stamp, I2C sucks, so this is why I've resorted to old beloved SPI

    I even have DS3231 board from ebay, but also can't get it to work.

    In fact, I was not able to get ANY I2C device to work (eeprom, light sensor, humidity sensor, etc).

  2. #2
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

    Default Re: DS1302 Problem, again :(

    I've tried to adapt the code from basic stamp, but it does not works:

    Code:
    include "MODEDEFS.BAS"
    DEFINE LCD_DREG PORTB
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTB
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTB
    DEFINE LCD_EBIT 1
    DEFINE LCD_BITS 4 
    DEFINE LCD_LINES 2
    DEFINE LCD_COMMANDUS 1500
    DEFINE LCD_DATAUS 44 
    
    define OSC 4
    
    DataIO VAR PORTC.2               ' DS1302.6
    Clock VAR PORTC.1               ' DS1302.7
    CS1302 VAR PORTC.3              ' DS1302.5
    
    WrSecs          CON     $80             ' Write Seconds
    RdSecs          CON     $81             ' Read Seconds
    WrMins          CON     $82             ' Write Minutes
    RdMins          CON     $83             ' Read Minutes
    WrHrs           CON     $84             ' Write Hours
    RdHrs           CON     $85             ' Read Hours
    CWPr            CON     $8E             ' Write Protect Register
    WPr1            CON     $80             ' Set Write Protect
    WPr0            CON     $00             ' Clear Write Protect
    WrBurst         CON     $BE             ' Write Burst Of Data
    RdBurst         CON     $BF             ' Read Burst Of Data
    WrRam           CON     $C0             ' Write RAM Data
    RdRam           CON     $C1             ' Read RAM Data
    Hr24            CON     0               ' 24 Hour Mode
    Hr12            CON     1               ' 12 Hour Mode
    
    
    index           VAR     Byte            ' Loop Counter
    reg             VAR     Byte            ' Read/Write Address
    ioByte          VAR     Byte            ' Data To/From DS1302
    secs            VAR     Byte            ' Seconds
    mins            VAR     Byte            ' Minutes
    hrs             VAR     Byte            ' Hours
    
    date            VAR     Byte
    month           VAR     Byte
    day             VAR     byte             ' Day
    year            VAR     Byte            ' Year
    
    ampm            VAR     hrs.BIT5        ' AM/PM Flag Bit
    clockMode       VAR     hrs.BIT7        ' 12/24 Hour Mode Bit
    ampmFlag        VAR     Bit             ' 0 = AM, 1 = PM
    modeFlag        VAR     Bit             ' 0 = 24, 1 = 12 (Hours)
    
    work            VAR     Byte            ' Work Data
    
    MAINLOOP:
    GOSUB GET_TIME
    lcdout $fe,1,"T:",#SECS, " ", #MINS, " ", #HRS, " "
    PAUSE 1000
    GOTO MAINLOOP
    END
    
    Get_Time:                               ' DS1302 Burst Read
      HIGH CS1302                           ' Select DS1302
      SHIFTOUT DataIO, Clock, LSBFIRST, [RdBurst]
      SHIFTIN DataIO, Clock, LSBPRE, [secs, mins, hrs, date, month, day, year]
      LOW CS1302                            ' Deselect DS1302
      RETURN
    Displays 0s....

  3. #3
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

    Default Re: DS1302 Problem, again :(

    Haha, found the reason, jumper wire was faulty !

  4. #4
    Join Date
    Feb 2013
    Posts
    1,132


    Did you find this post helpful? Yes | No

    Default Re: DS1302 Problem, again :(

    So code from the first post works properly, just checked.

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    967


    Did you find this post helpful? Yes | No

    Default Re: DS1302 Problem, again :(

    Aha - never underestimate the value of a visual inspection.

Similar Threads

  1. RTC Problem using DS1302
    By gavo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2010, 18:48
  2. TRIS setting for the DS1302
    By Dennis in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 3rd March 2010, 01:14
  3. Using the DS1302 scratchpad RAM ?
    By Kman in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 26th August 2007, 16:27
  4. DS1302 and 18F452
    By Astro in forum mel PIC BASIC
    Replies: 2
    Last Post: - 9th May 2006, 22:02
  5. Ds1302
    By willie in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd October 2005, 18:04

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts