Go Down

Topic: i2c slave at 32.5 khz (Read 1 time) previous topic - next topic

ulrichard

Feb 05, 2013, 01:28 am Last Edit: Feb 05, 2013, 01:29 am by ulrichard Reason: 1
I programmed an AtMega8 with arduino libraries using cmake to control a nokia display.
The AtMega8 is configured as an i2c slave to receive the instructions from an embedded linux box.
I tested it with a raspberrypi and it worked well.
Now I wanted to assemble it with a bifferboard, and it refuses to communicate. The device is not even listed with i2cdetect.
With the scope I found out that the raspberry pi's SCL runs at 100khz, which I read is the standard speed also for Arduino.
But the SCL of the bifferboard runs at only 32.5 khz. The BlinkM has no problem with that, but my AtMega8 does.
Now how could I make my AVR work as an i2c slave at 32.5 khz?

The full code is at : https://github.com/ulrichard/rfidtime/tree/master/nokia_display_i2c

I don't know it that's relevant, but the AtMega8 runs at 8Mhz, using an external resonator .While I think the old Arduino that used an AtMega8 was at 16Mhz. I set the frequency at the beginning of the cmake file. So, most timings work correctly, but I noticed that the tone() function is still off.

ulrichard

I found a thread where they explain how to change the i2c frequency :
http://www.windmeadow.com/node/42#comment-28
But my device still doesn't talk to the bifferboard.

ulrichard

I just tried communicating from the bifferboard to an attiny45 using  usiTwiSlave which is based on Application Note AVR312.
It worked! Unfortunately, this does work only on few AtMega's of which mine is not included.

Although I thought the Arduino Wire library activates internal pullups (not sure about slave mode though), just to be sure, I added some external pullups. But it didn't change anything.

This seems to be very strange. What are common problems with i2c communication?

So here is what works:
RaspberryPi  <->  AtMega8
RaspberryPi  <->  AtTiny45
RaspberryPi  <->  BlinkM
Bifferboard <->  AtTiny45
Bifferboard <->  BlinkM
Bifferboard <->  Duemillanove (ATmega328)
Bifferboard <->  ATmega328
Bifferboard <->  ATmega168

And here is what doesn't work:
Bifferboard <->  AtMega8

The ATmega328 and the ATmega168 had the exact same sketch loaded as the AtMega8.

Could it be the fuses?
AtMega328 :  lfuse FF   hfuse DA
AtMega8     :  lfuse FF   hfuse DD
Comparing them, I don't think it could have to do with BOOTRST.  I program the AtMega8 directly with an ICSP.

ulrichard

Next thing I flashed another AtTiny8 from the same shipment with the exact same sketch, and made sure it has the same fuse settings.
And guess what, with this one it works.
I verified it twice. With the same sketch and the same fuses, one of the AtMega8's communicates I2c with the bifferboard, and the other doesn't. And the one that doesn't, works well with other I2C masters.
Very strange...

Go Up