Hi guys,
There are a lot of topics like this but I can’t understand what’s going on here… I’m a programmer but a noob at electronics.
I’m having problems communicating with a SparkFun ADXL345 accelerator chip from a Baby Orangutan B-328 via I2C and Peter Fleury’s i2cmaster lib. I can init and start I2C with the correct address (0x53) but when I’m writing to it the code for waiting for ack just hangs. The chip works, I’m able to hook it up to my Raspberry Pi and read values from it no problem.
My code:
i2c_init();
i2c_start_wait(0x53 + I2C_WRITE);
i2c_write(0x2D, 0); // for example, anything fails
i2c_stop();
while (1) {}
The part of the i2cmaster i2c_write code that freezes:
// wait until transmission completed
while(!(TWCR & (1<<TWINT)));
I’m using a voltage divider to go from 5v to ~3.4v since the ADXL345 wants <3.6v.
I’m also using pull-up resistors of 4.7k for the SDA and SCL pins, which I’ve confirmed are pulling the pins to 3.4v.
The CS pin is pulled high to enable I2C.
The SDO pin is pulled low to enable the 0x53 address.
http://i.imgur.com/ycQIaaY.jpg?1What’s happening is, the i2c_write is pulling the pins low but then the SCL pin is never pulled high again… I guess that’s why it never leaves the loop? The SDA pin is being pulled high however (at a lower voltage though… like 2.9v). I’ve tried with different pull-up resistor values to no avail. As I said previously, the pull-ups does work when the i2c is not used (SDA and SCL are pulled high).
Anyone with some helpful advice? I’ve been battling this for several days now… Thanks.