Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Re: [AVR-Chat] I2C again

Re: [AVR-Chat] I2C again

2007-07-01 by John Samperi

At 08:26 AM 2/07/2007, you wrote:
>http://www.robot-electronics.co.uk/htm/srf08tech.shtml

I suppose you have looked at the code examples like the one for
the MAVERIC (M128), it is unfortunately in C but may be able
to just compile it and see if it works.

http://www.bdmicro.com/code/srf08/

Also the docs say that it behaves like a I2C EEPROM (24 series)
again it may be good to have something else to test your driver
code...if you could get that something else...

Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Email: john@ampertronics.com.au
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.476 / Virus Database: 269.9.14/883 - Release Date: 1/07/2007 12:19 PM

Re: [AVR-Chat] I2C again

2007-07-02 by David VanHorn

I made a little progress, I had the read/write bit inverted.
It acks now, but only address 0  E0 still does not.
Hammering away at it, I MAY have accidentally changed the address.

Now my problem is that I'm somehow not continuing with the transaction
after writing the address, and a "00" in the next byte which should be
followed by the $50 for ping with times in microseconds.

Somehow, I'm getting back out, and starting over with the start state
on the bus.

Puzzling, as the code is written that all error exits (at least I
THINK all..) are trapped, and give a 'ping code' that I should be
seeing on my LA.

Re: [AVR-Chat] I2C again

2007-07-02 by David VanHorn

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.

RE: [AVR-Chat] I2C again

2007-07-02 by larry barello

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.
Show quoted textHide quoted text
-----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

Re: [AVR-Chat] I2C again

2007-07-02 by David VanHorn

> AVR311 and AVR315 have pretty good descriptions of how TWI works.

Right.. What I'm wrestling with at the moment, is what the SONAR wants though.

I discovered one interesting thing today though..
You can START a ping using the broadcast address, but you CANNOT read
the data using the broadcast address.. !@#!@$!%   This makes sense IF
there are multiple devices on the bus, but in the limited testing case
where only one device is present, it left me chasing ghosts for a
while...  The acroname support people did not spot that error either.

> 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.

Hmm.. I'm not sure I understand.
If I address the device, and do a ripple-read of all the registers,
isn't that really the same as addressing the device multiple times and
reading only one register each time?  Or am I misunderstanding?

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.