STMicroelectronics / X-CUBE-MEMS1

X-CUBE-MEMS1 is an expansion software package for STM32Cube. The software runs on the STM32 and includes drivers that recognize the sensors and collect temperature, humidity, pressure and motion data.
https://www.st.com/en/embedded-software/x-cube-mems1.html
Other
54 stars 12 forks source link

Getting the data for the wrong accelerometer, instead of for IIS2ICLX #12

Closed bitsmaker closed 1 month ago

bitsmaker commented 1 month ago

Describe the set-up

Additional context

Hello,

I have attached the IKS02A1 to my NUCLEO-WB55RG. To the IKS02A1 I have attached STEVAL-MKI209V1K. The goal is to reproduce the setup and application from this ST video https://www.youtube.com/watch?v=S4JaNSnWeRw.

I have an application I have created in the IDE using X-CUBE-MEMS1's TiltSensing2_IIS2ICLX. When I use Unicleo-GUI, it connects to my app running on the board and I can see the data arrive. However, I noticed that the data is not for the IIS2ICLX accelerometer, it is for the accelerometers built into the ISK02A1. I know this because when I move the board with IIS2ICLX the data does not change. when I move the IKS02A1, it does

I have attached my app here ts_iis2iclx.zip

cparata commented 1 month ago

Hi @bitsmaker , you could try to put in the file "custom_motion_sensors.c" of your project at line 609:

io_ctx.Address = IIS2ICLX_I2C_ADD_L; /* SA0 = GND */

instead of

io_ctx.Address = IIS2ICLX_I2C_ADD_H; /* SA0 = VDD */

You can get the same result setting the SA0 pin parameter to GND in the CubeMX configuration inside CubeIDE. Best Regards, Carlo

bitsmaker commented 1 month ago

Ok thanks will try it once I am back this weekend. Thank you

bitsmaker commented 1 month ago

I tried that, but I error out in custom_motion_sensors.c line 101. I also get a failure in IIS2ICLX_0_Probe where IIS2ICLX_ReadID fails and the function IIS2ICLX_0_Probe returns BSP_ERROR_UNKNOWN_COMPONENT

Do I have to use a different I2C mode as mentioned here in section 2.2?

I also tried a simple experiment where I left the DIL24 socket on but disconnected the cable from the DIL24 socket to the board with the IIS2ICLX. The code in custom_motion_sensors.c at line 625 still detects the component with the ID 0x6B. That is unexpected! Is this because the ISM330DHCX on the IKS02A1 shares the same I2C address and device ID as IIS2ICLX

I am probably reading the schematic wrong but it seems SDO/SA0 is not connected to GND image

I am also looking at the DIL24 schematic, do the SB1, SB2, SB4, and SB5 correspond to jumpers? I ask because it looks like SA) could be connected to those image

bitsmaker commented 1 month ago

Are you able to test this with a real board on your side and provide me with the correct solution? It would be better if you were to take my app and modify it to work, test it in real hardware and then send me the modified app.

cparata commented 1 month ago

Hello @bitsmaker , as you can see in the attached picture, the SDO pin of the IIS2ICLX is connected to the pin 22 of the DIL24 socket that is put to GND through SB5 on the X-NUCLEO-IKS02A1 board. So, it is correct to use the lower I2C address in the source code. Are you sure that the DIL24 adapter is well connected to the DIL24 connector in your hardware setup? Pay attention to pin 1 of the adapter (the only squared pin) that should be connected to pin 1 of the connector indicated with a point in the PCB. Unfortunately, I don't have all the hardware boards to reproduce your setup, but if all the boards are well connected, you should be able to read at least the Device ID on your side. Best Regards, Carlo STEVAL-MKI209V1

bitsmaker commented 1 month ago

Thanks @cparata, I will check that tonight and get back to you

bitsmaker commented 1 month ago

image

This is how it's connected and as soon as I switch SA0 to GND, it cannot even read the ID

cparata commented 1 month ago

Hello @bitsmaker , Do you have a NUCLEO-F401RE or a NUCLEO-L152RE or a NUCLEO-L073RZ or a NUCLEO-U575ZI-Q? Just to check if the IIS2ICLX sensor works properly using one of the prebuilt "TiltSensing2_IIS2ICLX" applications that you can find in the X-CUBE-MEMS1 package. Best Regards, Carlo

bitsmaker commented 1 month ago

@cparata

I do not have any of those. I have a P-NUCLEO-WB55 image

cparata commented 1 month ago

Hello @bitsmaker , I checked your code and the main issue is that you are using a wrong INT1 pin. It's PC2 on WB55 board instead of PC4. So, please modify line 43 of the ''bsp_ip_conf.h" in this way:

#define BSP_IP_MEMS_INT1_PIN_NUM GPIO_PIN_2

I noticed also some wrong configurations on the DMA with respect to the original example of the TiltSensing2_IIS2ICLX. So, I suggest to use in your project the .ioc file inside the attached zip file and regenerate accordingly the source code to have the right behavior in the application. Best Regards, Carlo ts_iis2iclx_ioc.zip

bitsmaker commented 1 month ago

Thank you very much @cparata. I will try it tonight

bitsmaker commented 1 month ago

@cparata You da man!!!!!!! It is working!!! Thank you, thank you so much!! Can you please tell me what was wrong about the DMA config?

cparata commented 1 month ago

Great @bitsmaker ! Actually, I was wrong about DMA. DMA settings seem fine also in your IoC. But I noticed some differences in UART configuration and also Button configuration (you used the button pin as INT1 in your IoC). Anyway, the IoC that I provided to you should fix all issues. I will close the ticket. Best Regards, Carlo

bitsmaker commented 1 month ago

Thanks a lot @cparata