SPI not working with LSM6DSL
Hello,
I'm using NUCLEO-L476RG connected to eval board of LSM6DSL. I have checked the physical connection with a DVM and it seems to be correct.
I have generated a very simple project using STM32CubeIDE and trying to read the WHO_AM_I register (code below). I'm using a simple USB logic analyzer and I can see that the data is being output correctly on the MOSI line, but there is no answer on the MISO line. What am I missing here?
uint8_t who_am_I; // Who Am I
who_am_I |= 0x0f;
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(SPI1_nCS_GPIO_Port, SPI1_nCS_Pin, GPIO_PIN_RESET); //Set SPI CS to low
HAL_SPI_Transmit(&hspi1, &who_am_I, 1, 1000); // Read Who Am I register
while(HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY);
HAL_SPI_Receive(&hspi1, &pBuffer, 1, 1000);
// HAL_SPI_TransmitReceive(&hspi1, &who_am_I, &pBuffer, who_am_I, 1000);
HAL_GPIO_WritePin(SPI1_nCS_GPIO_Port, SPI1_nCS_Pin, GPIO_PIN_SET); //Set SPI CS to high
HAL_Delay(100);
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET);
HAL_Delay(100);
}