HAL SPI Slave Receive
Dear all,
I have a SPI Master, that sends out a "hello word" message working.
The signals are correct and my scope can decode them.
However, I can't, for the love of god get a slave working. Not DMA, not IT and not even
blocking mode.
Here is my code for init.
hspi1.Instance = SPI1;
hspi1.Init.Mode = SPI_MODE_SLAVE;
hspi1.Init.Direction = SPI_DIRECTION_2LINES;
hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi1.Init.NSS = SPI_NSS_HARD_INPUT;
hspi1.Init.FirstBit = SPI_FIRSTBIT_LSB;
hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi1.Init.CRCPolynomial = 7;
if (HAL_SPI_Init(&hspi1) != HAL_OK)
{
Error_Handler();
}then calling the receive method again and again,
but no matter when I break with the debugger, I always see 0s :
while (1)
{
uint8_t res = HAL_SPI_Receive(&hspi1, buffer, 5, HAL_MAX_DELAY);
// breaking here with debugger and looking into buffer - always 5 first bytes are zero
}What I really want is a DMA transfer (so, a callback when a message is complete), but I have given up on that thanks to the absolutely incomprehensible STs documentation for that so far. Just trying to receive any data in any way for now.
Any hints?
Thank you and best regards
Stefan
