Electrical – STM32 Spi receive problem

dmaembeddedmicrocontrollerspistm32

I'm trying to do simple SPI communication on STM32 Discovery, HAL lib is used. I'm trying to send some data via SPI1 and to receive same data on SPI3 (SPI1 = Full Duplex Master, SPI3 = Full Duplex Slave). For transmit polling method is used and for receive DMA circular. Communication is on 1 device (just one Discovery is used). Code stuck here:

while(HAL_SPI_GetState(&hspi3) != HAL_SPI_STATE_READY){}

Can someone explain me why code stuck there?

uint8_t rxSpi[10] = {0};
uint8_t txSpi[10] = "123456788";
    int main(void)
    {
        HAL_Init();
        SystemClock_Config();

        MX_GPIO_Init();
        MX_DMA_Init();
        MX_SPI1_Init();
        MX_SPI3_Init();
        MX_USART2_UART_Init();

        if(HAL_SPI_Receive_DMA(&hspi3, rxSpi, 10) != HAL_OK)
        {
            Error_Handler();
        }
        while(HAL_SPI_GetState(&hspi3) != HAL_SPI_STATE_READY){}

        while (1)
        {
            if(HAL_SPI_Transmit(&hspi1, txSpi, 10, 100) != HAL_OK)
            {
                Error_Handler();
            }
            while(HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY){}
            HAL_Delay(1000);
        }
    }

If I just send data (receive initialize is commented), on logic analyzer I got this, basically there is missing small interval between two bytes.
enter image description here

Best Answer

You should look at the API documentation or code. If you tell the SPI3 to receive 10 bytes via DMA, the state will be BUSY_RX until it has received those bytes. That is why the state is not ready.