Do I2CIN and I2COUT support clock stretching?
Zoot
Posts: 2,227
My guess right now is that they DO.
But I can't find anything in the documentation one way or the other. This came up while porting some code from a BS2p40 to an SX.
Anyone from Parallax have a definitive answer?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
But I can't find anything in the documentation one way or the other. This came up while porting some code from a BS2p40 to an SX.
Anyone from Parallax have a definitive answer?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Comments
-Phil
Post Edited (Phil Pilgrim (PhiPi)) : 8/13/2008 4:40:32 PM GMT
Phil, it is true that scl is driven without a pullup for the interpreter eeprom, but that does not apply to the regular pins. Both sda and scl require pullups.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
You're right, of course! The I2C commands have nothing to do with the onboard EEPROM. (That'll teach me post on the forums before I've had my morning coffee!) D'oh!
-Phil
Ahh, the coffee! Maybe you were cog-itating too hard and late last night on the phsx question (very interesting). I'm through my own cup of joe now, perking up.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
- I've used I2CIN I2COUT with an MD22 motor controller. That board is based on a PIC187Fx which clock stretches (under certain conditions)
- I built a simple I2C_SEND, I2C_RECV app in SX/B which failed utterly.
- when I used the beta SX/B, it worked. The only difference? The next release of SX/B supports clock stretching.
- lastly, it would seem that given the incredible ease of I2C on the Stamps that have these commands, if clock stretching were NOT supported, there would be folks having a whole lot more problems vis a vis Stamps/I2C
I spent two evenings trying to figure out why I couldn't read a register from the dang thing.... ugh.
PhiPi -- while the commands and the on-board eeprom don't answer any questions (that eeprom does not clock stretch), I actually think that the I2C commands are a kind of primitive on these flavor Stamps. I say this because of all the commands, I2CIN and I2COUT take up almost no code space (in fact, wrapping I2C commands in a subroutine often *increases* code space). I am guessing that since the Stamp itself spends a huge chunk of time fetching instructions via I2C from the token eeprom, that these are very basic and condensed to the whole shebang. Just a thought.
If anyone from Parallax is reading this -- a note about clock-stretching in the docs would be very helpful (if it's there already, I couldn't find it).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
BASIC Stamp® 2p Module Firmware Revision Details
There have been several tweaks made to the I2C command through the revisions up to the present v1.7. The IDE no longer supports versions earlier than 1.3. Clock stretching is not mentioned in the revision doc, which only goes back to v1.3, so it may have been a tweak in an earlier rev. I agree that is is a good thing to know, but clock stretching is not that common.
Another tidbit that is good to know is that the I2C commands do time out if they do not receive a response, so you don't have to worry that a program will hang on an I2c command if the device is defective or disconnected.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
I knew this from tests and experience (on the Stamps), but not for a fact. In my apps, if knowing if the device is online is important, I usually read a firmware register, or other known data at a register and compare it, if it's bad then the host knows the I2C devices is not responding (for whatever reason), e.g.
FW CON $99 ' or whatever
ioByte = 0
online = 0
I2CIN SDA, FirmRegister, [noparse][[/noparse] iobyte ]
IF iobyte = FW THEN
online = 1
ENDIF
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php