cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L051 SPI Slave DMA - last byte duplicated & doesn't terminate

daniel2399
Associate
Posted on September 26, 2014 at 00:26

Hi,

I have a problem with a SPI data transfer with DMA. I use a STM32L051 as SPI slave and created the code with STM32CubeMX.

I used the sample code as a reference and do something like this:

if (HAL_SPI_TransmitReceive_DMA(&hspi1, &txb, &rxb, 5) != HAL_OK)

{

/* Transfer error in transmission process */

}

while (HAL_SPI_GetState(&hspi1) != HAL_SPI_STATE_READY)

{

HAL_Delay(1);

The transfer never completes (HAL_SPI_GetState always returns busy). The bytes are transmitted to the SPI master but the last byte is wrong (duplicated from the byte before).

Before that I transfer a single byte (with the blocking function not with DMA) and that works. I also tried to use the blocking HAL function instead of the DMA version for transmitting the 5 bytes above but it also will not terminate.

I've spent hours on that, any ideas anyone?

Danny
1 REPLY 1
Posted on September 29, 2014 at 13:53

[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/STM32L051%20SPI%20Slave%20DMA%20-%20last%20byte%20duplicated%20%20doesn%27t%20terminate&currentviews=7]Duplicate thread !