cancel
Showing results for 
Search instead for 
Did you mean: 

HAL SPI DMA Transmit vs TransmitReceive

stigmablu
Associate II
Posted on May 30, 2015 at 04:14

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. #dma #hal #spi
0 REPLIES 0