Normally I2C is <address><r/w><data><data>...<stop> Where the data is originated/read depending upon the state of the r/w bit. Repeat stop is just a variation of the stop bit. It *still* has to be followed with the address & r/w bit of the device you want to access. After that the contents of the <data> is up to you and your peripheral. Typically and internal "register" or address or command is written, followed by some data (either written or read). AVR311 and AVR315 have pretty good descriptions of how TWI works. AVR316 has a description of SMBus which is a way of organizing the <data> within a transaction (r/w byte, r/w buffer, write command-read buffer, write buffer-read buffer. I used a variation of SMBus for a multi-drop project with ARM9 CPU, keypad, IMU and servo board - each with m128 processors. Works pretty well. My big hint: Keep your transactions stateless so the occasional corrupt packet doesn't mess things up (i.e. don't depend upon the results of a previous command like auto-incrementing a pointer. -----Original Message----- From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf Of David VanHorn Sent: Sunday, July 01, 2007 6:55 PM To: AVR-Chat@yahoogroups.com Subject: Re: [AVR-Chat] I2C again Ok, check me on this: To read a bunch of data from the devantech device: Send a start Write the address (with write bit cleared) as $00 Write another byte that says what register I want to read from (starting address) Issue 19 pairs of "read a byte" commands Issue a stop Or, do I have to do this: Send a start Write the address (with write bit cleared) as $00 Write another byte that says what register I want to read from Read a byte Issue a repeated start Write another byte that says what register I want to read from Read a byte Issue a repeated start (repeat till nauseous...) Issue a stop I have the first case written, but all I'm getting back is 00s. But I may need to check that it's been pinged, with all this hacking about I may have that turned off at the moment. Yahoo! Groups Links
Message
RE: [AVR-Chat] I2C again
2007-07-02 by larry barello
Attachments
- No local attachments were found for this message.