2021-09-07 01:41 AM
Hello,
I have difficulties to get value of 0x68(IMU) and 0x3D(Magnetometer) from LSM9DS1 WHO_AM_I Reg 0x0F.
I did on custom made board with STM32L083RZ and use I2C communication to LSM9DS1. I am using I2C3 PortC pin 0 and pin 1. The SDA&SCL are both pulled up with 4.7kOhm to VCC_MCU. CS_A/G Pin are pull-up to VCC_MCU without pullup resistor. And SDO_A/G and SDO_M pin are connected directly to STM32L0 at PortC_2 and PortC_3 which are then set(HIGH) as output_OpenDrain in GPIO Init() function. The address of slave would be 0x68<<1.
As I debug, I can see SDA& SCL are both correctly configured as Alternate Function OPEN DRAIN (AFRL=0x00000077). But the PROBLEM is I cannot read WHO_AM_I value with function below
HAL_I2C_Mem_Read (&hi2c3, LSM_ADDR_IMU|0x01,WHO_AM_I_REG,1, &check, 1, 1000);
I did change slave address to other value and it still did not return me 0x68.@
Can you help me? What is wrong.
Thank you in advance. @ST Community
Regards
Anuar
2021-09-07 02:59 AM
Does HAL_I2C_IsDeviceReady return HAL_OK? If not, there is a wiring issue.
Can you see what's happening on SDA/SCL with a logic analyzer?
What is the return value of HAL_I2C_Mem_Read? And if HAL_OK, what is the value of check?
2021-09-07 08:41 PM
Hello @TDK ,
thank you for answering me. :)
HAL_I2C_IsDeviceReady return HAL_OK. HAL_I2C_mem_read also returns HAL_OK of 0x00.
But I still have Who_Am_I problem which didnt return 0x68. In ISR Register of I2C_3, the BUSY FLAG is HIGH.
Do you have Idea? Thank you.
Regards
Anuar