Skip to main content
Associate II
April 1, 2025
Solved

LSM6DSV on STEVAL MKI239A with Nucleo board via SPI not working

hello

I've been trying to use the LSM6DSV on it's steval-mki239a board with a nucleo board (nucleo-l476rg) via SPI and the lsm6dsv is not answering whatever the configuration of my SPI is.

The sensor is fine since it work with the steval-mki109v3 board ans the MEMS studio

I checked the SPI signal on the steval mki109v3 with a logical analyzer and found several odd things but the sensor is answering

Eddess_0-1743493087888.png

I don't know if it is my analyzer but the MISO line is always stuck at 1 and the level of MOSI are strange but the sensor understand the message and answer with the right value (WHO_AM_I register:  MOSI should send 0x0F and MISO answer 0x70)

On the other end I tried to recreate the same configuration on my nucleo board but the sensor doesn't answer any command

I tried:

full duplex master CPOL=1 CPHA=1

Eddess_1-1743495078971.pngEddess_2-1743495176541.png

with external pull up on MISO

Eddess_5-1743495442778.png

full duplex master CPOL=1 CPHA=0

Eddess_3-1743495266676.png

with external pull up on MISO

Eddess_4-1743495321463.png

I tried in master half duplex

Eddess_7-1743495608417.pngEddess_6-1743495560968.png

with external pull up on MISO

Eddess_8-1743495684008.png

I tried master half duplex with CPHA =0 (1 edge)

Eddess_9-1743495806423.png

with external pull up on MISO

Eddess_10-1743495867881.png

I've been trying to make this work for more than a week now and tried all possible configuration but nothing works. what could be wrong? did I miss something?

I'm using the LSM6DSV library found here https://github.com/STMicroelectronics/lsm6dsv-pid/tree/7b98628713090244cf14f54d9059938cb00342fd that I adapted following the readme file

I attached my complete project

This topic has been closed for replies.
gabBest answer
Visitor II
April 3, 2025

Hi @Eddess,

Your problem here is in the implementation you made of the function platform_read.

Your implementation must first send the register you want to read and then receive a response but if you want the lsm6dsv to know that you want a response you must set the MSB of the register to 1 as stated in documentation.

 

Exemple :

static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len){
 reg |= 0x80; // Don't forget this line !
 HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
 HAL_SPI_Transmit(handle, &reg, 1, 1000);
 HAL_SPI_Receive(handle, bufp, len, 1000);
 HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
 return 0;
}

 

1 reply

gabBest answer
Visitor II
April 3, 2025

Hi @Eddess,

Your problem here is in the implementation you made of the function platform_read.

Your implementation must first send the register you want to read and then receive a response but if you want the lsm6dsv to know that you want a response you must set the MSB of the register to 1 as stated in documentation.

 

Exemple :

static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp, uint16_t len){
 reg |= 0x80; // Don't forget this line !
 HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
 HAL_SPI_Transmit(handle, &reg, 1, 1000);
 HAL_SPI_Receive(handle, bufp, len, 1000);
 HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
 return 0;
}