Question
LSM6DSM on SensorTile using SPI?
I would like to know what I am doing wrong or what register setting on the LSM6DSM that I missed setting?
Using a sensorTile (STM32L476JG) that is connected to LSM6DSM. APB1 Clk = 16MHz.
My settings are :
My code is trying to read WHO_AM_I register on the part, I get 0xC5 , should get 0x6A.
HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);
txBuf[0] = 0x12;
txBuf[1] = 0x08;
HAL_SPI_Transmit(&hspi2, txBuf, 2, 50);
HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);
/*
* disable i2c
*/
HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);
txBuf[0] = 0x13;
txBuf[1] = 0x04;
HAL_SPI_Transmit(&hspi2, txBuf, 2, 50);
HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);
/*
* who_am_I : should return 0x6a
*/
HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);
txBuf[0] = 0x0F | 0x80;
HAL_SPI_Transmit(&hspi2, txBuf, 1, 50);
HAL_SPI_Receive(&hspi2, rxBuf, 1, 50);
HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);