I am trying to transfer the data in SPI using DMA, where as my Hal status is HAL\_SPI\_STATUS\_BUSY\_TX. The required status is HAL\_SPI\_STATE\_READY. I want to send some bulk data and command(single byte) through SPI. Is it possible to switch between DMA and non DMA mode respectively. As shown in the image, it loops in the while.
[![enter image description here](https://i.stack.imgur.com/JSWV8.png)](https://i.stack.imgur.com/JSWV8.png)

```
hdma1_tx.Instance                 = DMA1_Stream7;
hdma1_tx.Init.FIFOMode            = DMA_FIFOMODE_DISABLE;
hdma1_tx.Init.FIFOThreshold       = DMA_FIFO_THRESHOLD_FULL;
hdma1_tx.Init.MemBurst            = DMA_MBURST_INC4;
hdma1_tx.Init.PeriphBurst         = DMA_PBURST_INC4;
hdma1_tx.Init.Request             = DMA_REQUEST_SPI1_TX;
hdma1_tx.Init.Direction           = DMA_MEMORY_TO_PERIPH;
hdma1_tx.Init.PeriphInc           = DMA_PINC_DISABLE;
hdma1_tx.Init.MemInc              = DMA_MINC_ENABLE;
hdma1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma1_tx.Init.MemDataAlignment    = DMA_MDATAALIGN_BYTE;
hdma1_tx.Init.Mode                = DMA_NORMAL;
hdma1_tx.Init.Priority            = DMA_PRIORITY_LOW;

if(HAL_DMA_Init(&hdma1_tx) != HAL_OK)
{
  // Error
}

/* Associate the initialized DMA handle to the the SPI handle */
__HAL_LINKDMA(hspi, hdmatx, hdma1_tx); 

/* Configure the DMA handler for Transmission process */
hdma_rx.Instance                 = DMA1_Stream1;
hdma_rx.Init.FIFOMode            = DMA_FIFOMODE_DISABLE;
hdma_rx.Init.FIFOThreshold       = DMA_FIFO_THRESHOLD_FULL;
hdma_rx.Init.MemBurst            = DMA_MBURST_INC4;
hdma_rx.Init.PeriphBurst         = DMA_PBURST_INC4;
hdma_rx.Init.Request             = DMA_REQUEST_SPI1_RX;
hdma_rx.Init.Direction           = DMA_PERIPH_TO_MEMORY;
hdma_rx.Init.PeriphInc           = DMA_PINC_DISABLE;
hdma_rx.Init.MemInc              = DMA_MINC_ENABLE;
hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_rx.Init.MemDataAlignment    = DMA_MDATAALIGN_BYTE;
hdma_rx.Init.Mode                = DMA_NORMAL;
hdma_rx.Init.Priority            = DMA_PRIORITY_HIGH;

HAL_DMA_Init(&hdma_rx);

/* Associate the initialized DMA handle to the the SPI handle */
__HAL_LINKDMA(hspi, hdmarx, hdma_rx);

/*##-4- Configure the NVIC for DMA #########################################*/ 
/* NVIC configuration for DMA transfer complete interrupt (SPI1_TX) */
HAL_NVIC_SetPriority(DMA1_Stream7_IRQn, 1, 1);
HAL_NVIC_EnableIRQ(DMA1_Stream7_IRQn); 

HAL_NVIC_SetPriority(SPI1_IRQn, 1, 0);
HAL_NVIC_EnableIRQ(SPI1_IRQn);

```

HAL\_STATUS must be HAL\_SPI\_STATE\_READY.

My data length is loaded in NDTR.
[![enter image description here](https://i.stack.imgur.com/FR2Bh.png)](https://i.stack.imgur.com/FR2Bh.png)

After SPI enabled NDTR = 0x00

[![enter image description here](https://i.stack.imgur.com/XO7VY.png)](https://i.stack.imgur.com/XO7VY.png)