DS1307 RTC - Advice please.


Closed Thread
Results 1 to 3 of 3

Hybrid View

  1. #1
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default Faulty module ?

    I've just loaded this code and this too shows 00:00:00 for date and time

    Code:
    @   __config _HS_OSC & _WDT_ON & _LVP_OFF & _CP_OFF  ; use this for 16F877a
    
    DEFINE  OSC 20
    CLEAR
    
    ;----[LCD definitions]------------------------------------------------------
    DEFINE LCD_DREG  PORTB              ' LCD Data port
    DEFINE LCD_DBIT  0                  ' starting Data bit (0 or 4)
    DEFINE LCD_EREG  PORTB              ' LCD Enable port
    DEFINE LCD_EBIT  5                  ' Enable bit  (on EasyPIC 5 LCD)
    DEFINE LCD_RSREG PORTB              ' LCD Register Select port
    DEFINE LCD_RSBIT 4                  ' Register Select bit   (on EasyPIC 5 LCD)
    DEFINE LCD_BITS  4                  ' LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2                  ' number of lines on LCD
    DEFINE LCD_COMMANDUS 2000           ' Command delay time in us 
    DEFINE LCD_DATAUS 50                ' Data delay time in us 
    
    SDA var PORTC.4                     ' RTC data 
    SCL var PORTC.3                     ' RTC clock
    
    TRISC= %11111111
    DB0 var byte[8]
    CMCON = %00000111                   ' Comparators = off
    gosub write_1307
    read_1307:                          ' Read time Secs,Mins,Hours,Day,Date,Month,Year,Control
    I2CREAD SDA,SCL,$D1,$00,[STR DB0\8] ' Read 8 bytes from DS1307
    
    lcdout $fe,1,"Time=",hex2 DB0[2],":",hex2 DB0[1],":",hex2 DB0[0]    'bit 0=sec, bit 1=min, bit 2=hrs
    lcdout $fe,$c0,"Date=",hex2 DB0[4],":",hex2 DB0[5],":",hex2 db0[6]  'bit 4=day, bit 5=month, bit 6=year
    goto read_1307
    end
    
    Write_1307:                          ' Set time & date to 19:00:00  14th Feb 201
    I2CWRITE SDA,SCL,$D0,$00,[$00,$00,$19,$7,$14,$2,$10,$90] ' Write to DS1307
    pause 10
    RETURN                               ' Sec Min Hr Day D M Y Control
    Guess the module is faulty

  2. #2
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default Doh! been a long day !

    I've sussed it !

    Some time ago I was using an 18F4550 which was set for USB comms



    Whilst I had scoured the data sheet I forgot that on the 18F4550 RC3 and RC4 are used for USB comms - a R of TFM has resolved the issue....

    Hours of frustration..... ERRRRR !

    Life's a learning curve !
    Attached Images Attached Images  
    Last edited by malc-c; - 22nd March 2010 at 21:21.

Members who have read this thread : 0

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