2020-05-08 11:04 PM
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);
}
2020-05-11 09:57 AM
Hi @DRote.2297 , can you check the MISO and MOSI line with an oscilloscope, if you are getting something like 00h or FFh? Btw, I suggest you to check the STM32CubeL4 firmware package, both in the folder \Drivers\BSP\Components\lsm6dsl, which contains the LSM6DSL drivers for the STM32L4 MCU family and the folder \Projects\NUCLEO-L476RG\Examples\SPI for checking the correct SPI initialization on NUCLEO L4 platform. Regards
2020-05-11 10:14 AM
Hi @Eleon BORLINI , unfortunately I don't have an oscilloscope. I have a USB logic analyzer - when I use it I see FFh.
I initiated the SPI using STM32CubeIDE, tried few different SPI configurations but the result is always the same. What else can it be?