I2C/TWI - hunt for understanding

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have searched with out great success and again need guidance, probably the phrase or correct words.

is there any preferred articles regarding AT90can128(or atmega)communication to an Arduino uno based chip using the I2C?

I am using peter Fleury's TWI lib and the Arduino wire lib but there seems to be a miss match. im not sure but think it is to do with the addressing 7 or 8 bit addresses.

the AT90 seems to output the correct wave form on the bus but the Arduino is not responding.

Pull ups fitted I presume correct speed at 90k (11.22 us)

is I mentioned ive tried all sorts of Google phrases but don't seem to be able to find the correct answer.
any pointers are welcome.

I can get two Arduinos talking master slave no problem.

Nigel

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The 7-bit / 8-bit address thing has bitten me in the past too. It looks like Arduino uses the 7-bit address. I'm not familiar with Fleury's TWI lib.

Typical bus speed on I2C is 100kHz and I think Arduino Wire lib defaults to that. FWIW. I bet you can get away with 10k resistors but to be sure rise time isn't too bad maybe 4.7k or ... ?

You could try writing an I2C address scanner, perhaps, on the master. Easiest if you can just issue start, write(addr) check ack, then stop. Got any other devices you can use as a master? RPi? (i2cdetect) Propeller (I have a spin object that you can use), mbed, etc?

You know the biggest help to me in working with I2C was a logic analyzer. I was using an HP1650A (no decode) then thought I'd save money and get one of those Open Workbench Logic Sniffers but when I was loaned a Seleae Logic I wished I'd saved a bit extra. I ended up buying one of the Seleae devices once I realized how incredibly fast and flawlessly they work.

If you want to post up code, feel free and I'll take a look when I get some time.

Meanwhile you can investigate whether the TWI library uses 8 or 7 bit addresses.

Hope this helps. I've been doing a lot of I2C lately :)

MIchael

It should work - bot-thoughts.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Michael,

Yes the wire lib does use 7 bit and the TWI uses 8 bit. I am not sure how to change either.

I use a ChronoVu 8 bit... works fine for me.

Im still going to research this till it works.

Nigel

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You should find that both Fleury (8-bit) and (7-bit) work fine as Masters.
Only does slave.

Most problems arise because the punter can't afford real external pull-up resistors.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ok David. Well I must be rich! I have 2x 4k7 resistors to 5v. Mainly because I know its the main thing us punters don't fit!

Nigel

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

shouldn't the bit highlighted be a zero if its coming out of the master? the address of the slave is 4 and again I am sending 3 bytes (like the SPI).

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Something looks wrong to me. I2C transmits MSB first. I don't see any ACKs at all. Surely your software would report the bad transfer.

You are using a Slave with 7-bit address of 0x02. 8-bit addresses 0x04/0x05

What is your slave address supposed to be. All libraries will tell you when you get a bad (NAK) reply.

Your blue arrow is pointing at the NAK (bit-9 @ 90us)

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Horaa... it works and I have a small increase of understanding of I2C.there must be a weak connection as it just started working.

watch out can bus people!! that's next. thanks for the help

nigel