I2C timer (or other I2C device) on BS2, BS2SX, etc.
Carl Hayes
Posts: 841
Many devices (such as the Gravitech I2C-RTC real time clock) communicate by the I2C protocol.· Only the most advanced Stamps (BS2P, BS2PE, BS2PX) support this natively in firmware.· I thought it would be nice if I could avoid that expense by running I2C devices on a BS2SX.· Also I wanted to be able to put the I2C device on any pins I chose, not just 0-1 or 8-9.· I've tested on a BS2, BS2SX, and BS2P24.
It took about a day to develop the code to do this, and I thought others might be interested.· I have attached a copy of the code that does this for me.· It will, I think, work with almost any I2C device, but in particular it is designed to work with the Maxim (Dallas Semiconductor) DS1340 clock chip that is used in the Gravitech real time clock.· It would require modification for use with other I2C devices, but the mods would be easy.
With the DS1340, it will (1) set the clock, (2) read the clock, (3) adjust the clock to run slower, and (4) adjust the clock to run faster.· I've included a little utility, as a demo, that can be used just as provided here, to do these things through DEBUG.· It's kind of nice to be able to adjust the speed of the clock, for those things are often a little off, right out of the box.
I hope this will be useful to someone besides me.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i
It took about a day to develop the code to do this, and I thought others might be interested.· I have attached a copy of the code that does this for me.· It will, I think, work with almost any I2C device, but in particular it is designed to work with the Maxim (Dallas Semiconductor) DS1340 clock chip that is used in the Gravitech real time clock.· It would require modification for use with other I2C devices, but the mods would be easy.
With the DS1340, it will (1) set the clock, (2) read the clock, (3) adjust the clock to run slower, and (4) adjust the clock to run faster.· I've included a little utility, as a demo, that can be used just as provided here, to do these things through DEBUG.· It's kind of nice to be able to adjust the speed of the clock, for those things are often a little off, right out of the box.
I hope this will be useful to someone besides me.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i
bsx
19K
Comments
on STAMP WORK it has been explained and in a shorter code wich you can adapt for anything else..
anyway .. thank you
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i
The Code in StampWorks is Experment.#33 pg.188 using the DS1307 and not the DS1340. I'm pretty sure StampWorks is a Free download
and a ?ed copy can be pur$$. It can be found on the Parallax web-site.
The code for the DS1307 is a bit long for My liking w/ a I2C bus. I'll check out the code you posted for the DS1340. Thanks for sharing Your code... Mr.Hayes
________________________________$WMc%________________________on the D.L._________
Post Edited ($WMc%) : 11/2/2008 7:25:08 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i
Your comments and information have been extremely helpful (unlike that other fellow, who was only dismissive), and I am very grateful to you.· So, simply -- Thanks!·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i
But you with the strange name of $WMc% have (1) taught me something, and (2) enabled me to improve my code. May your days be long, and may you people the earth with your get.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Rick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i
The communications is by 3 or 4 lines, Chip Select, Clock, Data In and Data Out.
There must be one unique Chip Select line to each device, all others can be bussed. This is it's big disadvantage vs I2C. SPI can run at many MHz vs 400KHz (I think) for I2C, this is maybe it's biggest advantage over I2C.
There is much more info here:
en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Rick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i