Skip to main content
Visitor II
April 12, 2020
Question

LSM6DSO issue connecting to AUX SPI

  • April 12, 2020
  • 2 replies
  • 1832 views

Hi,

I have trouble using LSM6DSO via the AUX SPI - MISO is always high.

I verified via the primary interface (I2C) that register WHO_AM_I (0Fh) returns 6Ch.

I tried to change VDD after reading this post:

  • VDD=3.3V: reading register CTRL1_OIS (70h) with the primary interface returns 0 (WHO_AM_I returns correct value).
  • VDD=1.8V: reading register CTRL1_OIS (70h) with the primary interface returns FFh (WHO_AM_I returns correct value).

My HW setup:

STEVAL-MKI196V1 connected to NUCLEO-G071RB.

VDD and VDDIO were changed for both boards during the test.

SPI signals look fine in the oscilloscope.

SPI configuration in SW:

 hspi1.Instance = SPI1;
 hspi1.Init.Mode = SPI_MODE_MASTER;
 hspi1.Init.Direction = SPI_DIRECTION_2LINES;
 hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
 hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
 hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
 hspi1.Init.NSS = SPI_NSS_SOFT;
 hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_256;
 hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
 hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
 hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
 hspi1.Init.CRCPolynomial = 7;
 hspi1.Init.CRCLength = SPI_CRC_LENGTH_DATASIZE;
 hspi1.Init.NSSPMode = SPI_NSS_PULSE_DISABLE;

main.c loop SPI reading (both options don't work):

uint8_t reg = 0x0F;
uint8_t bufp[2] = {0,0};
while (1) {
	 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_RESET);
 
// option 1:
	 status = HAL_SPI_Transmit(&hspi1, &reg, 1, HAL_MAX_DELAY);
	 status = HAL_SPI_Receive(&hspi1, bufp, 2, HAL_MAX_DELAY);
// option 2:
	 status = HAL_SPI_TransmitReceive(&hspi1, &reg, bufp, 1, HAL_MAX_DELAY);
 
	 HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0, GPIO_PIN_SET);
	 HAL_Delay(1);
 }

Best regards,

Yiftah

    This topic has been closed for replies.

    2 replies

    ST Employee
    April 14, 2020

    Hi @Yiftah​ , did you enabled the Mode 3 or Mode 4 on the sensor, for the auxiliary AUX SPI enabling, as reported in the datasheet p. 26?

    "Mode 3 is enabled when the OIS_EN_SPI2 bit in CTRL1_OIS (70h) register is set to 1. Mode 4 is enabled when both the OIS_EN_SPI2 bit and the Mode4_EN bit in CTRL1_OIS (70h) register are set to 1."

    I'm not sure to have caught your comment here:

    I tried to change VDD after reading this post:

    • VDD=3.3V: reading register CTRL1_OIS (70h) with the primary interface returns 0 (WHO_AM_I returns correct value).
    • VDD=1.8V: reading register CTRL1_OIS (70h) with the primary interface returns FFh (WHO_AM_I returns correct value).

    Are you facing issue when Vdd=1.8V?

    Regards

    YiftahAuthor
    Visitor II
    April 14, 2020

    Hi @Eleon BORLINI​ ,

    I cannot enable mode 3 or mode 4 because this requires writing to register CTRL1_OIS (70h). According to the datasheet, only Aux SPI can write to this register. But I cannot make the Aux SPI work. I have only I2C communication (LSM6DSO's primary interface).

    I haven't got a clue what is causing the Aux SPI to fail.

    I shared my code because it may be that I got wrong the SPI initialization, or maybe the write/read functions.

    I tried many different things, but none seems to have any effect, except changing the VDD, which affected the I2C.

    I don't know if this is related to the SPI not working, so I shared the results here.

    Best regards,

    Yiftah

    ST Employee
    April 15, 2020

    Hi @Yiftah​ , ok I understand... when you write >>SPI signals look fine in the oscilloscope, which is the pattern on SDO_Aux pin? Regards

    YiftahAuthor
    Visitor II
    April 16, 2020

    Hi @Eleon BORLINI​ ,

    SCLK (pin 3) + MOSI (pin 2):

    0693W000000VuhsQAC.jpg

    SCLK (pin 3) + MISO (pin 11):

    0693W000000Vuj9QAC.jpg

    Best Regards,

    Yiftah