9 years, 3 months ago.

I2C Problem?

Hi,

sorry poor English. I have connected the MMA8451Q in I2C to SSCI824.

MMA8451Q Datasheet

Import programSSCI824_I2Ctest

SSCI824 I2C Test Don't work.

When I run the same program in the LPC1768 is no problem.

In the case of LPC1768, MMA8451 was reply to 0x1A of device ID.

However, in the case of SSCI824, MMA8451 was reply the 0x00 of device ID.

/media/uploads/mark8018/ssci824_i2c_problem.png

Question relating to:

The Switch Science mbed LPC824 operates at CPU frequencies of 30 MHz. The LPC824 includes up to 32 kB of flash memory, up to 8 kB of data memory, four …

1 Answer

9 years, 3 months ago.

Do you have 'Pull Up' resistors (value 4k7 - 10k) on the SDA and CLK connections of the i2c bus?

Accepted Answer

Thank You for responce. Yes, I have 'Pull Up' resistors (value 10k) on the SDA and CLK.

posted by Manabu Taniguchi 28 Dec 2014

IMHO, 10k is too weak, specially at 400KHz and/or multiple devices hanging off the I2C bus. Try 2.2k - 3.3k range.

Also, have you double checked the pin names called out for SDA and SCL in your code? All 4 wires (SDA, SCL, VCC, GND) are wired correctly?

posted by Kevin Braun 28 Dec 2014

Thank You for responce. I checked the connection again. and, I changed the pull-up resistor to 2.2K of the SCL and SDA. However, response of ID was 0x00. Correctly is 0x1A.

/media/uploads/mark8018/ssci824_photo.jpg This photo is the hardware environment.

Also, check with LPC11U35QSB was work correctly. What would the problem?

posted by Manabu Taniguchi 29 Dec 2014

I found the problem.

MMA8451 is requested by reading the Repeated Start Condition. However, LPC824 is stopped.

My souce code

#define I2C_ADDRES (0x1c<<1)

    memset(temp, 0, sizeof(temp));
    temp[0]=0x0D; // REG_WHO_AM_I
    if(i2c.write(I2C_ADDRES, temp, 1, true) != 0) pc.printf("I2C write error\r\n");
    memset(temp, 0, sizeof(temp));
    if(i2c.read(I2C_ADDRES, temp, 1, false) != 0) pc.printf("I2C read error\r\n");
    pc.printf("ID is %X\r\n",(int)temp[0]); // ID is 0x1A

    memset(temp, 0, sizeof(temp));
    temp[0]=0x2A; // REG_CTRL_REG1
    temp[1]=0x19; // Data
    if(i2c.write(I2C_ADDRES, temp, 2, false) != 0) pc.printf("I2C write error\r\n");

I2C Bus Sequence

LPC1768OKST, 38, AK, 0D, AK, ST, 39, AK, 1A, NK, SPST, 38, AK, 2A, AK, 19 AK, SP
LPC824NGST, 38, AK, 0D, AK, SP, ST, 39, NK, 00, NK, SPST, 38, AK, 2A, AK, 19 AK, SP

I will take a look at the mbed-src.

posted by Manabu Taniguchi 29 Dec 2014