0

This is the MCU: http://www.microchip.com/wwwproducts/en/ATtiny88 - it advertises a hardware I2C interface, but I am struggling with it. It is mounted on my own board (which worked fine if I dropped an ATMega instead).

edited - prev screencapture were from an ungrounded logic analyzer

First tried the Femtocow ATTiny - it has complained about no Wire library at the #include Wire.h line. So i went into C:\Program Files\Arduino\hardware\arduino\avr\libraries, grabbed the Wire folder and copied it into C:\Program Files\Arduino\libraries. Compiled fine, loaded the binary with avrdude, got a few first TWI communication fine, then it started trashing.

Second attempt was with the cores from Drazzy ATTinycore which came with its own Wire library. Compiled fine, loaded the binary and got the same behaviour.

This is how the messed up I2C line looks in both cases. Starts fine, then appears to go wonky, after a few of these wonky bursts the lines go silent. Also, in spite of having changed the frequency to both 100 and 400 kHz i have this weird 1.953 kHz clock...

#define F_TWI             400000L
//#define F_TWI             100000L

....

  Wire.begin(); // Initiate the Wire library
  Wire.setClock(F_TWI);

enter image description here

I am using Arduino 1.8.2. Anything gives ?

  • Circuit or wiring? And pullup resistors? – Mikael Patel Oct 13 '17 at 9:00
  • It is a PCB, equipped with two 3k3 pullups – kellogs Oct 13 '17 at 9:21
  • These implementations are only partially in hardware - while software doesn't twiddle the bits, it has to poke the hardware for each edge. The invalid SDA transitions may well be caused by an analog issue - try smaller (stronger) pullups, make sure no peripheral is loading the bus, ideally look with a scope not a logic analyzer. – Chris Stratton Oct 13 '17 at 17:08
  • @ChrisStratton I am afraid i am not so advanced to posses an oscilloscope :) What values did you have in mind ? Maybe some 470 Ohm ? The rail is 3.3 V – kellogs Oct 14 '17 at 7:17
  • Just tried the 470 Ohms, same outcome. I don't suppose this could be a bad PCB since there is the exact same behaviour on each attempt. Maybe I ought to replace the MCU... – kellogs Oct 14 '17 at 9:18
0

My issue has ultimately come from some memory differences between the ATTiny88 and the ATMega88 - the latter has twice as much SRAM - 1 kB. There normally have not been any warnings on this running out of RAM issue except for once - can't recall how but Arduino IDE did warn.

However, until I got to the bottom of it there have been some digging that had to be done. Like getting used to the programmer either working as expected, or erroring and failing, or erroring and not failing. Then there are the, sometimes changing, folders into which Arduino IDE outputs its files. Also there are non-working board configurations causing the used Wire libraries to issue read and write requests followed by just a NAK. Oh, and not to forget about the messed up signals - turns out they weren't messed up, just the logic analyzer was.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.