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
你好,summer20100514!

你好,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年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

在Dialog提供的智能标签发布项目中,我找到了一个i2c加速度计mc3410的驱动程序文件,也许会有所帮助。

JE_Dialog
Offline
Last seen:5 days 7 hours 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:5 days 7 hours ago
工作人员
加入:2013-12-05 14:02
你好,我是Summer20100514

你好,我是Summer20100514attach 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\u示例…DA14580\u peripheral_设置.uvproj

step 2. see: periph_setup.h:
将硬件配置索引(.)更改为“1”。

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

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

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

挥发温度;
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.

莫希特3112
Offline
Last seen:6 months 2 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
等待\u接收到\u BYTE()?

谢谢

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

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

莫希特3112
Offline
Last seen:6 months 2 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.

莫希特莱
Offline
Last seen:4年6个月前
加入:2016-07-28 20:57
any one get the solution of

任何人都能解决这个问题………因为我也遇到同样的问题,我的代码也被困在ptrI2C->GetStatus()的无限循环中。

莫希特莱
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.