Dallas DS3232 Extremely Accurate RTC
Dave-W
Posts: 94
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.
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
How do I move it? I did not realize I was in the wrong Forum.
Sorry,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave W.
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 Savage
Parallax Engineering
·
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..
Chris, Great site for information. Goto savagecircuits.com
Dave,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dave W.
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.