0

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

1 Answer 1

1

AFAIK HAL_SPI_RxCpltCallback is only triggered by an DMA interrupt. You should either try to change HAL_SPI_Receive_IT to HAL_SPI_Receive_DMA or implement the handler for HAL_SPI_Receive_IT in the xxx_it.c file.

From my point of view (with very little experience at this specific topic ...) it looks like you're waiting on the wrong interrupt.

Sign up to request clarification or add additional context in comments.

1 Comment

I realized the NSS pin was pulled out wrong on my custom hardware. Thank you! Best, Gil

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.