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

15个帖子/ 0新
Last post
summer20100514
Offline
Last seen:4年2个月前
格鲁鲁
加入: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?
谢谢。

VesaN
Offline
Last seen:5年4个月前
格鲁鲁 Master
加入:2014-06-26 08:49
你好夏天20100514!

你好夏天20100514!

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年4个月前
格鲁鲁 Master
加入:2014-06-26 08:49
一个有趣的事情

一个有趣的事情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.

因此,检查您的从地址右,0011000或0011001

summer20100514
Offline
Last seen:4年2个月前
格鲁鲁
加入:2014-12-30 05:01
谢谢for your reply. I have

谢谢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年4个月前
格鲁鲁 Master
加入:2014-06-26 08:49
Unfortunately I'm not aware

不幸的是,我不知道da1458x芯片会有任何。也许你可以分享你的驱动程序的一些代码?

谢谢!

summer20100514
Offline
Last seen:4年2个月前
格鲁鲁
加入:2014-12-30 05:01
In the release project of

在对话框提供的智能标签的发布项目中,我发现用于一个I2C加速度计的驱动程序文件MC3410,也许会有所帮助。

JE_Dialog
Offline
Last seen:15 hours 55 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:15 hours 55 min ago
工作人员
加入:2013-12-05 14:02
你好夏天2014年,我

你好夏天2014年,我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:
将硬件_configuration_index(。)更改为'1'。

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

  • (0) SPI FLASH MEMORY WITH UART
  • (1)I2C EEPROM与UART
  • (2) QUADRATURE ENCODER WITH BUZZER AND UART
    *---------------------------------------------------------
    */
    // 硬件配置<0 => SPI闪存与UART <1 =>带有UART <2 =>正交编码器,定时器和蜂鸣器,带有UART
    #定义HARDWARE_CONFIGURATION_INDEX (1) // 1 => I2C

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

挥发性int16_t温度;
volatile int ii;

// testing peripheral SE95 temperature sensor
//地址= 1001 a2 a1 a0 r / w => 7bitaddress = 0x48 ... 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年2个月前
格鲁鲁
加入: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
专家
加入: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()?

谢谢

summer20100514
Offline
Last seen:4年2个月前
格鲁鲁
加入:2014-12-30 05:01
you should check pullup

您应该先检查上拉电阻和从机地址,您应该更好地使用逻辑分析仪。祝好运

Mohit3112.
Offline
Last seen:6 months 3 weeks ago
专家
加入: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年2个月前
格鲁鲁
加入: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年6个月前
加入:2016-07-28 20:57
any one get the solution of

任何一个人都得到了这个问题的解决方案.........因为我也得到了同样的问题,我的代码也被困在ptri2c-> getstatus()的无限循环中。

Mohit Rai.
Offline
Last seen:4年6个月前
加入:2016-07-28 20:57
我也得到了相同的

我也得到了相同的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.