Nucleo-64 STM32L452RE Issue SPI MISO
Hello,
I'm a little confused about the SPI communication. I tried to get the MCP2515 working with the STM32, but I end up at the beginning because I can't read data from the SPI. Both the HAL_SPI_TransmitReceive and HAL_SPI_Receive functions give me STATUS_OK, but an empty Rx buffer. I have tried to link MOSI and MISO together to isolate MCP2515, but no luck, zero data.
This code has generated the graphs from the oscilloscope below, but the rx buffer is still empty:
HAL_GPIO_WritePin(CAN_CS_GPIO_Port, CAN_CS_Pin, GPIO_PIN_RESET);
uint8_t spitesttx[2];
uint8_t spitestrx[2];
spitesttx[0] = 0xAA;
spitesttx[1] = 0x55;
HAL_SPI_TransmitReceive(&hspi3,spitesttx, spitestrx, 2, 10);
SPI_rx1 = spitestrx[0];
SPI_rx2 = spitestrx[1];
HAL_GPIO_WritePin(CAN_CS_GPIO_Port, CAN_CS_Pin, GPIO_PIN_SET);Scope of 1-CS, 4-CLK and 3-MOSI/MISO wire.


My SPI configuration:
hspi3.Instance = SPI3;
hspi3.Init.Mode = SPI_MODE_MASTER;
hspi3.Init.Direction = SPI_DIRECTION_2LINES;
hspi3.Init.DataSize = SPI_DATASIZE_8BIT;
hspi3.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi3.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi3.Init.NSS = SPI_NSS_SOFT;
hspi3.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
hspi3.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi3.Init.TIMode = SPI_TIMODE_DISABLE;
hspi3.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi3.Init.CRCPolynomial = 10;
__HAL_RCC_SPI3_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/**SPI2 GPIO Configuration
PB3 ------> SPI2_SCK
PB4 ------> SPI2_MISO
PB5 ------> SPI2_MOSI
*/
GPIO_InitStruct.Pin = GPIO_PIN_3|GPIO_PIN_5;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_4;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Alternate = GPIO_AF6_SPI3;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);I tried the SPI2 circuit before, with the same result.
Could you please help me, what could be wrong?
Thank you, Jan.
