I2C storage issue


Closed Thread
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default I2C storage issue

    hi,

    Is it possible to store a value from a ds1307 chip: something like:

    time[8]

    timer(0) = I2CREAD SDA,SCL,$D1,$00,[STR DB0\8]
    .... snip ...
    timer(1) = I2CREAD SDA,SCL,$D1,$00,[STR DB0\8]


    K

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


    Did you find this post helpful? Yes | No

    Default

    Not sure if it's what you are after, but (thanks to other forum members) use the following routine to place the data from a DS1307 into variables which are then used to compare set times and alarms, and these are then saved in the memory part of the PIC and recalled in the event of a power failure

    Code:
    I2CRead SDApin,SCLpin,$D0,$00,[RTCSec,RTCMin,RTCHour,RTCWDay,RTCDay,RTCMonth,RTCYear,RTCCtrl]  ; read DS1307 chip
    
    timeH=(RTCHour>>4)                               'convert the BCD format of the hours register and store in variable timeH
    timeH=(timeH &$03)*10
    timeH=timeH+(RTCHour&$0F)
    
    timeM=(RTCMin>>4)
    timeM=(timeM &$07)*10
    timeM=timeM+(RTCMin&$0F)                         'convert the BCD format of the mins register and store in variable timeM
    Last edited by malc-c; - 19th November 2010 at 17:23.

  3. #3
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Or use an ST M41T81 in place of the DS1307. It automatically stores a timestamp whenever it goes on battery power allowing you to track power failure durations.

  4. #4
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default

    The way I see its going towards array and long!!, unless there is another method.
    A simpler description of what I am looking is:

    I2Cread time1
    record time1
    ...code...
    I2Cread time2
    record time2
    ...code...
    I2Cread time3
    record time3
    ...code...

    So I can keep 100 different times

    K

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