Shop OBEX P1 Docs P2 Docs Learn Events
Dallas DS3232 Extremely Accurate RTC — Parallax Forums

Dallas DS3232 Extremely Accurate RTC

Dave-WDave-W Posts: 94
edited 2010-02-18 04:26 in BASIC Stamp
Hello All,
I·am just starting to program my BS2P to interface my new DS3232 Date / Time IC.
Here is some code I just started with and I would like to know if I am on the right track or way out in left field. According to PBasic the address is not needed. It says:

·Note that some devices like the PCF8574 do not require an internal address, so this parameter is optional (BS2p firmware 1.3 or later is required to omit the Address parameter).

So, I am using the Slave ID as the Memory address for the DS3232. Will this work?
Will this work?

' {$STAMP BS2p}
' {$PBASIC 2.5}
·
' ========================================================================
·
'
[noparse][[/noparse] Program Description ]

·
' This code will interface the BS2p, BS2pe and BS2px to a Dallas DS3232 maybe
·
'
[noparse][[/noparse] I/O Definitions ]

·
SDA··········· PIN····· 0············· ' I2C Serial Data Line
SCL··········· PIN····· 1············· ' I2C Serial Clock Line
·
'
[noparse][[/noparse] Variables ]

·
TimeDate········· ········ VAR····· Byte·········· ' Variable Used To Store Value
DS3232_Start_add··· VAR····· Byte·········· ' DS3232 Start+ counter address to put Data
Counter······················ VAR··· ·· Byte············ ' Loop counter for Data Address
'
Preset Data

'
DS3232_Start_add···· =$00
Counter· ···················· = 00····
'
I2COUT SDA, ID+COUNTER, [noparse][[/noparse]TimeDate]
·
' This will loop until all time and date data has been transferred.

Any suggestions welcome,
Dave

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave W.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-16 02:28
    Please read the sticky thread "PLEASE READ BEFORE POSTING PROJECTS! (Completed Projects Forum Guidelines)". Your thread doesn't fit the guidelines for this forum. Better would have been the Sandbox or the Stamp forum.
  • Dave-WDave-W Posts: 94
    edited 2010-02-16 03:01
    Mike,
    How do I move it? I did not realize I was in the wrong Forum.
    Sorry,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave W.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-16 04:19
    Only one of the forum administrators can move it. I wanted you to read and understand the guidelines.

    I think you need to reread the datasheet for the DS3232, particularly the pictures of the I2C communications and compare those to the descriptions of the various I2C statement of the BS2p series. My reading of the datasheet tells me that the device select code is $D0 and the device behaves otherwise like a 256 byte RAM or EEPROM with one byte of address information given in the I2CIN or I2COUT statements. If you want to read the control/status byte, you'd do:

    I2CIN SDA,$D0,$0F,[noparse][[/noparse] statusValue ]

    If you want to write to the control/status byte, you'd do:

    I2COUT SDA,$D0,$0F,[noparse][[/noparse] controlValue ]

    If you want to read or write the SRAM, you'd use addresses $14 through $FF instead of $0F shown above.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2010-02-16 13:59
    This thread is being moved from the Completed Projects Forum to the BASIC Stamp forum.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    ·
  • Dave-WDave-W Posts: 94
    edited 2010-02-18 03:39
    Hello Mike,

    Thank you for your input. Now, so I can understand this I re-read the spec sheet several times. Here is the information I do think I understand.

    For a Data Write:

    Start bit, Slave addess of 1101000 = $68, write command of $00 for slave to read, receive the ACK bit, send word address [noparse][[/noparse] $00 if it is seconds ], receive the ack bit, send the·Data.

    Am I on the right track?

    Also,

    Many thanks to Chris for the forum correction. Next time I will be awake before I post..nono.gif

    Chris, Great site for information. Goto savagecircuits.com

    Dave,





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave W.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-02-18 03:48
    Well, not quite. The I2CIN and I2COUT statements expect that the device address is represented as it would be sent as a byte to the device along with the read/write bit which is provided by the statement. The device address item in the statement would be $D0 as I said (read the description of the statements in the Reference Manual). The I2CIN / I2COUT statements take care of sending the "word" address and handle the ACK bits.
  • Dave-WDave-W Posts: 94
    edited 2010-02-18 04:26
    Mike,
    Give me a few moments to digest what you have tried to tell me and thank you that you did take your time to explain. However, I will re-read the spec sheet again and look at the BS2 I2c commands again. Thanks much. I do not doubt you, it is me that is in the dark for now. I now know that the ACK is handled by the BS2 command but It may take me a few hours to understand the device address... More reading to do.
    Thanks

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave W.
Sign In or Register to comment.