I am working on a project where I am using two boards to communicate via SPI. The master board (TMS320F28377S) is sending data successfully via SPI, I'm attaching a screenshot of the scope with CLK, MOSI, and SS pins. master data
Now, my receiver board is running on a STM32F439 processor, I'm relatively new to this micro. I configured it as a a Receiver Only using CubeMX, rest of settings are show below,
hspi2.Instance = SPI2;
hspi2.Init.Mode = SPI_MODE_SLAVE;
hspi2.Init.Direction = SPI_DIRECTION_2LINES_RXONLY;
hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
hspi2.Init.NSS = SPI_NSS_HARD_INPUT; //??
//hspi2.Init.NSS = SPI_NSS_SOFT;
hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
hspi2.Init.CRCPolynomial = 10;
As it can be seen on scope, CPHA and CPOL settings are matched for both boards (low clk when idle, and sample on leading edge).
Once the code is ready for receiving, I call the following,
if(HAL_SPI_Receive_IT(&hspi2, (uint8_t *)GEU_RX_Buffer, 2) != HAL_OK)
{
Error_Handler();
}
while(1){}
I'm placing a breakpoint in the, setting a variable and calling receive interrupt again
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi)
{
Sys_Mode = DIAGNOSTIC_MODE;
// Trigger interrupt again to keep receiving datas
HAL_SPI_Receive_IT(&hspi2, (uint8_t *)rx_buffer, 2);
}
When I make a transfer from master, I'm watching rx_buffer variable and no data is being received, also RXNE flag is not being set.
Is there something I'm missing here? All I want is to be able to receive data on another platform in non-blocking mode using interrupt. Also, should I have the NSS pin physically connected to an I/0 on the receiver micro?
Your help is appreciated in advance.
Thank you.
Gil
question from:https://stackoverflow.com/questions/65942955/stm32f4-spi-receive-interrupt-not-working