AnsweredAssumed Answered

HAL SPI DMA Transmit vs TransmitReceive

Question asked by meini.marco on May 30, 2015
Hi, when dealing with SPI with DMA this works:

SPI_CS_on();
if(HAL_SPI_TransmitReceive_DMA(&hspi2, &dataout, &input, 1) != HAL_OK) { /* error */ }
while (HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY) { /* wait */ }
SPI_CS_off();

while this doesn't (blocking program flows):
SPI_CS_on();
if(HAL_SPI_Transmit_DMA(&hspi2, &dataout, 1) != HAL_OK)  { /* error */ }
while (HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY)  { /* wait */ }
SPI_CS_off();


the only way to have HAL_SPI_Transmit_DMA to work is by using it AFTER HAL_SPI_TransmitReceive_DMA or after manually calling __HAL_SPI_ENABLE(&hspi2); like so:
__HAL_SPI_ENABLE(&hspi2);
dataout = 0x85;
 
SPI_CS_on();
if(HAL_SPI_Transmit_DMA(&hspi2, &dataout, 1) != HAL_OK)  { /* error */ }
while (HAL_SPI_GetState(&hspi2) != HAL_SPI_STATE_READY)  { /* wait */ }
SPI_CS_off();


any idea? is HAL_SPI_Transmit_DMA supposed to work this way?

thanks.

Outcomes