cant tick DS1307 please help......


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2011
    Posts
    5

    Default cant tick DS1307 please help......

    Hello there....

    a newbie in picbasic... and i cant start the ds1307....i can read it and i know that..when i discnnet battery it turn to 01/01/01 kiriaki (sunday)
    here is my code...

    my xtal is 32768 , 3v battery Li , 0,1μF cap in power, and 4,7k registors in data/clock pins.....

    please help....thank you (sorry my English is no good)



    dEFINE LOADER_USED 1 'Bootloader Used
    define osc 4
    define lcd_dreg portd 'LCD define
    define lcd_dbit 4
    define lcd_rsreg portd
    define lcd_rsbit 3
    define lcd_ereg portd
    define lcd_ebit 2
    define lcd_bits 4
    define lcd_lines 2


    pause 1000

    SDA Var PORTB.0
    SCL Var PORTB.1

    RTCYear Var Byte
    RTCMonth Var Byte
    RTCDate Var Byte
    RTCDay Var Byte
    RTCHour Var Byte
    RTCMin Var Byte
    RTCSec Var Byte
    RTCCtrl Var Byte


    TRISB= %11111111


    RTCYear = $11
    RTCMonth = $12
    RTCDate = $26
    RTCDay = $02
    RTCHour = $10
    RTCMin = $33
    RTCSec = $10
    RTCCtrl = $10

    settime:

    I2CWrite portb.0, portb.1, $D0, $00, [RTCSec, RTCMin, RTCHour, RTCDay, RTCDate, RTCMonth, RTCYear, RTCCtrl]
    pause 15


    gettime:
    I2CRead portb.0, portb.1, $D0, $00, [RTCSec, RTCMin, RTCHour, RTCDay, RTCDate, RTCMonth, RTCYear, RTCCtrl]
    pause 10
    TOGGLE portc.7

    if rtcday=1 then Lcdout $fe, 1, hex2 RTCMonth, "/", hex2 RTCDate, "/" , hex2 RTCYear , " Kiriaki"
    if rtcday=2 then Lcdout $fe, 1, hex2 RTCMonth, "/", hex2 RTCDate, "/" , hex2 RTCYear , " Deutera"
    if rtcday=3 then Lcdout $fe, 1, hex2 RTCMonth, "/", hex2 RTCDate, "/" , hex2 RTCYear , " Triti"
    if rtcday=4 then Lcdout $fe, 1, hex2 RTCMonth, "/", hex2 RTCDate, "/" , hex2 RTCYear , " Tetarti"
    if rtcday=5 then Lcdout $fe, 1, hex2 RTCMonth, "/", hex2 RTCDate, "/" , hex2 RTCYear , " Pempti"
    if rtcday=6 then Lcdout $fe, 1, hex2 RTCMonth, "/", hex2 RTCDate, "/" , hex2 RTCYear , " Paraskeui"
    if rtcday=7 then Lcdout $fe, 1, hex2 RTCMonth, "/", hex2 RTCDate, "/" , hex2 RTCYear , " Savvato"
    Lcdout $fe,$c0, hex2 RTCHour, ":", hex2 RTCMin, ":", hex2 RTCSec

    pause 490

    goto gettime

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: cant tick DS1307 please help......

    I have quickly scanned your code, I think you enabled the SQRWAVE OUT do you see any activity on this, by testing with logic probe or 'scope ?

    If no activity then

    Do you have the correct crystal ?

    Data sheet says

    Connections for Standard 32.768kHz Quartz Crystal. The internal oscillator circuitry is
    designed for operation with a crystal having a specified load capacitance (CL) of 12.5pF.
    X1 is the input to the oscillator and can optionally be connected to an external 32.768kHz
    oscillator. The output of the internal oscillator, X2, is floated if an external oscillator is
    connected to X1.
    Note: For more information on crystal selection and crystal layout considerations, refer to
    Application Note 58: Crystal Considerations with Dallas Real-Time Clocks.


    Also check

    Bit 7 of Register 0 is the clock halt
    (CH) bit. When this bit is set to 1, the oscillator is disabled. When cleared to 0, the oscillator is enabled. On first
    application of power to the device the time and date registers are typically reset to 01/01/00 01 00:00:00
    (MM/DD/YY DOW HH:MM:SS). The CH bit in the seconds register will be set to a 1.

    Have you tried it without the backup battery, to do this you must ground the battery backup pin
    ...

  3. #3
    Join Date
    Dec 2011
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: cant tick DS1307 please help......

    Aerostar thanks for the reply....
    my xtal is 32768 rectangular face (not cylindrical )... is not a Quartz?? i dont know...

    i have read data sheet talking about the.. Bit 7 of Register 0 is the clock halt
    (CH) bit...but i dont know how to clear it....(have in mind that my English is not good)

    if U could show me how...i use the i2cwrite statement as U see for my programming..

    yes i know about the battery.... i hane a 3V Li and when i disconnect it the lcd show 01/01/01 Sunday 01:01:01..

    Thanks man!!

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: cant tick DS1307 please help......

    When you write to the seconds register location 0 with $10, then you are clearing the bit automatically as the byte will be in binary 00010000, so bit 7 will be a zero and the clock will run.

    The shape of the crystal is not important, it is the specification that is important. Do you have any specification of the crystal you have ?

    If the crystal has a different load capacitance (CL) greater or smaller than 12.5pF, the chip will either not run or if it does run then the speed may not be 32768.

    Which PIC are you using ? and what speed is it running at ?

    Depending on the Pic and speed you may have to put the following DEFINE in your program.

    The timing of the I2C instructions is set so that standard speed devices (100KHz) will be accessible at clock speeds up to 8MHz. Fast mode devices (400KHz) may be used up to 20MHz. If it is desired to access a standard speed device at above 8MHz, the following DEFINE should be added to the program:
    DEFINE I2C_SLOW 1

  5. #5
    Join Date
    Dec 2011
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: cant tick DS1307 please help......

    thank U friend again!!
    my pic is a 16f877 4Mhz xtal....
    i think that my ds107 crystal is the problem...as i have note in youtube videos only cylindrical xtal are using...!!!!
    and when i press mine the lcd snow up one sec!!!!
    my xtal is a Hosonic 32768 B221....
    the problem is now that....in my small town i cant find cylidrical xtals!!!

  6. #6
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    579


    Did you find this post helpful? Yes | No

    Default Re: cant tick DS1307 please help......

    Check if DS1307 work with one LED, like in picture !
    Attached Images Attached Images  

  7. #7
    Join Date
    Dec 2011
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: cant tick DS1307 please help......

    Fratello no it does not.....but i have news i almost destroy my crystal and with a small weight on it...it working!!!!!
    not so good is true..but my lcd is changing numbers at last!!!
    i think that my crystal is the problem.... i think a cylictrical xtal is nessesary to work ds1307...in youtube videos
    every crystal i saw is a small cylidrical....
    now how seconds are change and the led is not flashing...i dont know!!!!!!
    thank 4 the reply

  8. #8
    Join Date
    Dec 2011
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: cant tick DS1307 please help......

    .....ok.............
    i bought a 32768 Mhz xtal instead of a 32768 Khz?????????????????
    YES!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    thanks folks for all replies!!!
    happy new years day!! with many electro-cookings!!!!

  9. #9


    Did you find this post helpful? Yes | No

    Default Re: cant tick DS1307 please help......

    Hi Did you get your code eventually working ??? Do you mind sending me the code I am trying to get the very similar thing going only want to sent the time out via Rs232

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