Hi guys,
I’ve been battling this for a few days now, I’m a programmer but kind of a noob at electronics so I’m kinda hoping it’s my wiring. I know there are a lot of threads around on this subject but I’ve been through all of them.
Basically I have a Baby Orangutan B-328 hooked up to a SparkFun ADXL345 via I2C using Peter Fleury’s i2cmaster lib. But it hangs at i2c_start, i.e. at this line:
// twimaster.c (i2c_start)
// send START condition
TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN);
// wait until transmission completed (HANGS)
while(!(TWCR & (1<<TWINT)));
The simplest code I have that hangs is:
i2c_init();
i2c_start(0x53 + I2C_WRITE);
i2c_stop();
while (1) {}
The ADXL345 wants <=3.6v so I’ve used a voltage divider (5v > 1000/2200 = 3.4v) and measured 3.4v at the pins.
The SDA and SCL pins are connected to SDA and SCL respectively, and I have pull-up resistors at 4.7k and I’ve measured 3.4v on all the pins.
The SDO pin is pulled low for the 0x53 address.
The CS pin is pulled high to Vcc for I2C mode.
Here’s an image of my setup: ('scuse the messy pull-ups and SDA/SCL wires, I had proper jumpers and stuff but I was testing things)
The ADXL chip works - I’ve got it hooked up to my Raspberry Pi and I’m getting readings from it with that.
The address 0x53 is correct - it works on the Pi (but the code never gets to the address bit anyway).
I’ve also tried both the TWI and the software (assembler) version of the i2cmaster lib with the same results.
I’ve set the clock frequency to 20mhz for the TWI version, and the pins to 4 and 5 on the C port for the software version.
I also have a BlueMate Bluetooth chip on the serial port just to be able to communicate some debugging (which works fine).
I’ve given up on trying to solve this myself… Anyone with some helpful advice? Thanks.