I2C slave
Frasse
Posts: 11
Can SX/B be used to create an I2C slave? The example shown in the Online Help only indicates it's I2C commands usage in a master setup.
If it can be used in a slave setup, does anyone have an example?
I'm especially·confused about how to address the master when supplying data as a response to a·request for data by the master. What address do you give the master? Do you have to provide I2CSTART and I2CSTOP or do you just do I2CSEND?
Any information would be appreciated.
If it can be used in a slave setup, does anyone have an example?
I'm especially·confused about how to address the master when supplying data as a response to a·request for data by the master. What address do you give the master? Do you have to provide I2CSTART and I2CSTOP or do you just do I2CSEND?
Any information would be appreciated.
Comments
It is possible to take a portion of Assembly language and insert it within SX/B code.
The idea of 'addressing the master' is a bit confusing. While I2C has a 2 wire bus [noparse][[/noparse]plus ground], there is often one or more 'address pins' that tell the I2C slave that the master is using that particlar device. Some devices have only one 'address pin' and others might have as many as three [noparse][[/noparse]usually ram or eeprom].
The actual software communication [noparse][[/noparse]if that is what you mean by addressing] is done through having an active high data line and an active high clock line. If the slave wants to slow down or delay the master, the clock line is 'pulled low' by the slave and the master recognizes this signal to suspend transmission until high again.
I am not sure, but I believe that in some cases an ACK [noparse][[/noparse]acknowledge] may be sent by the slave to confirm receipt of a message.
Conceptually speaking, I2CStart and I2cStop are controling the begining and ending of the serial clock line. I2CSEND moves data through the serial data line. Of course, the devil is in the details and nothing beats thorough study of what is I2C protocol and how it differs from the other serial protocols [noparse][[/noparse]like SPI and Microwire]. But don't get too bogged down in concepts because you are likely to find a particular device has to be taylored to.
So, if you have a device in mind and a project, just try to use that to build a sucessful use. You will come to grips with both the concepts and the reality.
Also, don't get confused with ONE-WIRE which has device addresses and even a CRC function. It is a quite ambitions distraction that seems only suited for a few particular applications [noparse][[/noparse]like a network of temperature gauges in a grain elevator or a chemical process].
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
SX/B's commands do not implement either slave I2C or multi-master I2C, you will have to program them in assembly yourself. Take a look at Parallax's application notes for the SX on thier downloads page, it should help you get started implementing the extra functionality. Also here is a site that provides a general overview of the way I2C does what I describe above: http://www.esacademy.com/faq/i2c/
There is·the official documentation on·the I2C protocol, but it is fairly long and Id have to hunt for it abit.·
Here is the Parallax pdf·and code·for I2C.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 1/26/2006 3:54:17 PM GMT
Just for knoledge,
it striked my eyes today that in the help page for the I2C commands of SxB, there is a minor but potentially serious printing error:
it say.....
Pin defines the SDA pin of the I2C bus. Pin may any IO pin except RA.3 (RA.7 on the SX52), RB.7, RC.7, RD.6, or RE.6 (see below).
should not it be something like this?
Pin defines the SDA pin of the I2C bus. Pin may be any IO pin except RA.3 (RA.7 on the SX52), RB.7, RC.7, RD.7, or RE.7 (see below).
Warmest regards
Stefano
post edited minor english sintax errors
Post Edited (ellizard) : 1/26/2006 7:16:42 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 1/26/2006 7:27:09 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan