cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 SPI DMA not working

Gabriel T
Senior

Hello,

When I use DMA with SPI it is not working.

0693W000007BGY9QAO.pngWhen I get a falling edge on DRDY this function gets called :

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
	if(GPIO_Pin == DRDY_ADC_Pin)
	{
		HAL_SPI_Receive_DMA(&hspi1, SPI1_RxBuffer, READBACK_LENGTH);
	}
}

SPI1 RX Buffer is located in a DMA accessible memory, RAM D2 (it works I checked the .map) :

uint8_t __attribute__(( section(".ramd2section"))) SPI1_RxBuffer[READBACK_LENGTH]; // SPI Tx

My question is do I need to use a setup function outside of what HAL_SPI_MspInit() already does. For example HAL_MDMA_Start_IT() ?

I've red few posts with the same problem but the solution is never explicated or done not using only HAL function.

What I use :

SPI1 Master full-duplex

DMA1 Stream 2 SPI1_Rx to SPI1_RxBuffer

MDMA Stream 0 SPI1_RxBuffer to ads_buf located in DTCMRAM

11 REPLIES 11
Gabriel T
Senior

Yes when I use it without DMA, It sends "dummy" data in order to receive. The Tx buffer ptr is the same as the Rx one so it echoes the message

Gabriel T
Senior

I will write my own driver and switch to half duplex