I have been stuck into the i2c driver of lis3dh for almost one week, what should I do

15 posts / 0 new
Last post
summer20100514
Offline
Last seen:4 years 2 months ago
Guru
加入:2014-12-30 05:01
I have been stuck into the i2c driver of lis3dh for almost one week, what should I do

Hi, everyone here. Recently I get engaged into one project which the lis3dh is used. There are some constraints, so I have to choose the i2c driver instead of spi. And as you can see, I tested the spi driver once and everthing worked well. But when it turns to i2c, I get stuck into the driver for almost one week without making any progress. I read all the posts here about i2c and nothing helps. I only tried to read back the content of WHO I AM register, and used one logic analyzer to monitor the i2c bus, and the result is that no ACK is get responsed from lis3dh after some suggested initialization procedure. So can anybody here help me get out of the deadlock by giving me some advice? For example, should I develop some code to simulate the i2c bus instead?
Thanks.

VesaN
Offline
Last seen:5 years 4 months ago
Guru Master
加入:2014-06-26 08:49
Hello summer20100514!

Hello summer20100514!

There are a lot of things you could try.. What have you tried so far? You could double check pin configuration, you could check Chip Select (CS) pin is pulled high on your accelerometer to select I2C bus etc..

VesaN
Offline
Last seen:5 years 4 months ago
Guru Master
加入:2014-06-26 08:49
One interesting thing too

One interesting thing too from datasheet:

The Slave Address associated to the LIS3DH is 001100x. SDO/SA0 pad can be used to modify less significant bit of the device address. If SA0 pad is connected to voltage supply, LSb is 1 (address 0011001b) else if SA0 pad is connected to ground, LSb value is 0 (address 0011000b). This solution permits to connect and address two different accelerometers to the same I2C lines.

So, check you have the Slave Address right, either 0011000 or 0011001

summer20100514
Offline
Last seen:4 years 2 months ago
Guru
加入:2014-12-30 05:01
Thanks for your reply. I have

Thanks for your reply. I have checked what you mentioned above at least 5 times, so I think there must something wrong in the chip or something else? And what's more, is there any demo project or .c file that has been tested before which works well on some chips, for example, adxl345?

VesaN
Offline
Last seen:5 years 4 months ago
Guru Master
加入:2014-06-26 08:49
Unfortunately I'm not aware

Unfortunately I'm not aware there would be any for DA1458x chips. Maybe you can share some code of your driver?

Thanks!

summer20100514
Offline
Last seen:4 years 2 months ago
Guru
加入:2014-12-30 05:01
In the release project of

In the release project of Smart Tag provided by Dialog, I found driver files used for one i2c accelerometer, mc3410, maybe that will help.

JE_Dialog
Offline
Last seen:13 hours 43 min ago
工作人员
加入:2013-12-05 14:02
Hello summer20100514, did you

Hello summer20100514, did you take a look at the i2c EEPROM driver example in teh perhipherals project ? whilst its not a sensor, it is generic i2c command .

BR JE_Dialog

JE_Dialog
Offline
Last seen:13 hours 43 min ago
工作人员
加入:2013-12-05 14:02
Hello Summer20100514, I

Hello Summer20100514, I attach below an example for an SE95 i2c temperature sensor for referebce. The i2c API is fairly robust : we have a couple of customers who are in produciton with i2c MEMS and no reported problems of i2c API .

BR JE_Dialog

SDK … \peripheral_examples … DA14580_peripheral_setup.uvproj

step 2. see: periph_setup.h:
change the HARDWARE_CONFIGURATION_INDEX (.) to ‘1’.

/* Test Definition - Select the Configuration that matches your H/W setup
*---------------------------------------------------------

  • (0) SPI FLASH MEMORY WITH UART
  • (1) I2C EEPROM WITH UART
  • (2) QUADRATURE ENCODER WITH BUZZER AND UART
    *---------------------------------------------------------
    */
    // Hardware Configuration <0=> SPI Flash with UART <1=> I2C EEPROM with UART <2=> Quadrature Encoder, Timers & Buzzer with UART
    #定义HARDWARE_CONFIGURATION_INDEX (1) // 1 => I2C

step 3.
add new software in: eeprom_test.c (at the beginning of the file)

volatile int16_t temperature;
volatile int ii;

// testing peripheral SE95 temperature sensor
/ /地址= 1001 A2 A1 A0 R / W = > 7 bitaddress x = 048 ... 0x48 + 7 = 0x4F

i2c_eeprom_init(0x48, I2C_STANDARD, I2C_7BIT_ADDR, I2C_1BYTE_ADDR);

// reading internal ID-number:
ii = i2c_eeprom_read_byte(0x05); // test reading ID-value = 0xA1

// reading temperature
btrd = i2c_eeprom_read_data(rd_data, 0, 2);

temperature = 256 * rd_data[0]+ rd_data[1];
temperature = temperature / 8; // shift 3 bits to right

summer20100514
Offline
Last seen:4 years 2 months ago
Guru
加入:2014-12-30 05:01
@BR JE_Dialog, thanks for

@BR JE_Dialog, thanks for your attention and patience.

mohit3112
Offline
Last seen:6 months 3 weeks ago
Expert
加入:2014-08-04 13:45
Hey Summer20100514,

Hey Summer20100514,

Is your problem solved , i am facing the same problem with adxl345 , i have tried the eeprom example code it gets stuck at
WAIT_FOR_RECEIVED_BYTE() ?

Thanks

summer20100514
Offline
Last seen:4 years 2 months ago
Guru
加入:2014-12-30 05:01
you should check pullup

you should check pullup resisters and slave address first, and you should better use a logic analyzer. Good luck

mohit3112
Offline
Last seen:6 months 3 weeks ago
Expert
加入:2014-08-04 13:45
i am using 4.7k pullups for

i am using 4.7k pullups for lis3dh but it's not working for me (got adxl working by the way thanks !!) . what pullup resister are you using , also if SDO is grounded 7-bit slave address is 0x18 ( as we are excluding the read write bits) ?

summer20100514
Offline
Last seen:4 years 2 months ago
Guru
加入:2014-12-30 05:01
Yes, there is something still

Yes, there is something still confuses me. My colleague is working on this, and he said to me he added some delay between i2c functions and it seemed working well, so you can try this. And if you make any progress, please be kind to post here for references, thanks.

mohit rai
Offline
Last seen:4 years 6 months ago
加入:2016-07-28 20:57
any one get the solution of

any one get the solution of this porblem .........because i am also getting same problem my code is also stuck in infinite loop at ptrI2C->GetStatus() .

mohit rai
Offline
Last seen:4 years 6 months ago
加入:2016-07-28 20:57
i am also getting same

i am also getting same problem ...my code is also stuck in infinite loop at "ptrI2C->GetStatus().busy" .........what is the solution of this problem? if any body solve this problem then please tell the solution.thanks in advance.