cancel
Showing results for 
Search instead for 
Did you mean: 

LSM6DSO issue connecting to AUX SPI

Yiftah
Associate II

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

8 REPLIES 8
Eleon BORLINI
ST Employee

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

Yiftah
Associate II

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

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

Hi @Eleon BORLINI​ ,

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

0693W000000VuhsQAC.jpg

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

0693W000000Vuj9QAC.jpg

Best Regards,

Yiftah

Hi Yiftah, also MOSI output seems not good... can you check the standard SPI communication between the master NUCLEO-G071RB and the slave STEVAL-MKI196V1? Are you correctly managing the CS pin? Maybe is not an issue of the aux interface but of the SPI at master level... Regards

This is the CS pin:

0693W000000VvzNQAS.jpg

Hi @Eleon BORLINI​ , can you please give more details what exactly is wrong with the MOSI signal?

Yiftah

More information about the issue:

I noticed that in Figure 8 in the DS the first bit should be high for reading, so I added "| 0x80":

#define LSM6DSO_REG_WHO_AM_I  0x0F
...
while (1)
{
bufp[0] = LSM6DSO_REG_WHO_AM_I | 0x80;
status = HAL_SPI_Receive(&hspi1, bufp, 2, HAL_MAX_DELAY);
}

Now this is the MOSI signal:

0693W000000W3TUQA0.png

But there is no change in the MISO signal - always HIGH :weary_face:

I also tried to disconnect the MISO from the master, connect only to the oscilloscope, and enable/disable the pull-ups with PIN_CTRL (02h); but MISO is not changing (with pullup - always HIGH, without pullup - always LOW).

Yiftah