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.
Mon, 2015-01-12 07:40
#1
I have been stuck into the i2c driver of lis3dh for almost one week, what should I do
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..
One interesting thing too from datasheet:
So, check you have the Slave Address right, either 0011000 or 0011001
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?
Unfortunately I'm not aware there would be any for DA1458x chips. Maybe you can share some code of your driver?
Thanks!
In the release project of Smart Tag provided by Dialog, I found driver files used for one i2c accelerometer, mc3410, maybe that will help.
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
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
*---------------------------------------------------------
*---------------------------------------------------------
*/
//
#定义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
@BR JE_Dialog, thanks for your attention and patience.
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
you should check pullup resisters and slave address first, and you should better use a logic analyzer. Good luck
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) ?
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.
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() .
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.