2021-09-13 05:59 AM
Hi, it's my first experience with MCUs in general.
In this first approach I try to read outputs from MKI159V1 (LSM9DS1) with the nucleo F446RE. I'm starting with I2C protocol. I read any kind of articles here in the community but I still can't work it.
Let's start from reading the default value in the register WHO_AM_I (0x0F) that has to return 104 if the module is detected.
First question
The acceleration and gyroscope SAD+R/W imu address to read in a register are 0xD5 and 0xD7. Can I choose indifferent between them and why two type of address? Have I connect any physical pin (Pin 22 SDO) to GND or Vdd?
Second question
I think my issues start from conneting the module to the mcu. My settings are:
Vdd (Pin 1) -> 3V3;
Vdd_IO (Pin 2) -> 3V3;
SCL (Pin 20) -> D15;
SDA (Pin 21) -> D14;
CS_A/G (Pin 19) -> Vdd_IO;
GND (Pin 13) -> GND ;
What's wrong?
In the STM32CubeIDE, with right settings in Pinout & Configuration of .ioc file, simply using this function, HAL_I2C_Mem_Read(&hi2c1, IMU_ADD_R1, WHO_AM_I, 1, &check, 1, 1000), where I choose IMU_ADD_R1 0xD5, with the function HAL_UART_Transmit i'm not able to read in the register.
Thanks for any type of answer and sorry for basic questions.
2021-09-30 05:26 AM
Hi @Occio ,
Let me try to answer to your question from the sensor point of view.
>> The acceleration and gyroscope SAD+R/W imu address to read in a register are 0xD5 and 0xD7. Can I choose indifferent between them and why two type of address? Have I connect any physical pin (Pin 22 SDO) to GND or Vdd?
Yes, you can choose the two of them indifferently, by connecting the SDO pin either to GND (resulting in the I2C address 0xD5), or to Vdd (resulting in the I2C address 0xD7). In this way, if you have two sensors on your application board, you can connect them to the same I2C (SDA and SCL) lines, since they will have different I2C addresses. See also the datasheet, p.30.
>> Pins configuration
If you are using the I2C communication, you have to pull-up the following lines with a proper resistor:
SCL (Pin 20) -> D15;
SDA (Pin 21) -> D14;
See also the general STEVAL-MKI159V1 circuit schematic.
If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster.
-Eleon