cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7 DMA Circular Mode Not Circulating

Bill Finger
Associate III

I'm using an STM32F769 for a project. I'm trying to continuously stream ADC samples to a buffer. I can fill the buffer without issue, but the DMA never recirculates back to the beginning. I don't get any DMA errors, and the ADC is still running (I can see the DR value change in the debugger if I halt).

Any ideas? The DMA configuration is below.

// Intermediate buffers for DMA streaming.

static struct tag_sample_buffer {

uint16_t samples[2][1024];

} sampleBuffer[3];

DMA_InitTypeDef dmaInit;

dmaInit.Direction = DMA_PERIPH_TO_MEMORY;

dmaInit.PeriphInc = DMA_PINC_DISABLE;

dmaInit.MemInc = DMA_MINC_ENABLE;

dmaInit.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;

dmaInit.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;

dmaInit.Mode = DMA_CIRCULAR;

dmaInit.Priority = DMA_PRIORITY_HIGH;

dmaInit.FIFOMode = DMA_FIFOMODE_DISABLE;

dmaInit.FIFOThreshold = DMA_FIFO_THRESHOLD_HALFFULL;

dmaInit.MemBurst = DMA_MBURST_SINGLE;

dmaInit.PeriphBurst = DMA_PBURST_SINGLE;

hDma[0].Init = dmaInit;

hDma[0].Instance = DMA2_Stream0;    // stream for ADC1 event

hDma[0].Init.Channel = DMA_CHANNEL_0; // channel for ADC1 event

HAL_DMA_Init(&hDma[0]);

... ADC config, immaterial

// Associate the initialized DMA handle to the ADC handle:

__HAL_LINKDMA(&hAdc[0], DMA_Handle, hDma[iAdc]);

// Configure the NVIC for the DMA transfer complete interrupt.

HAL_NVIC_SetPriority(DMA_IRQS[0], ADC_DMA_GRP, ADC_DMA_PRIO);

HAL_NVIC_EnableIRQ(DMA_IRQS[0]);

// Start the ADC and DMA. It will wait for the trigger timer.

result = HAL_ADC_Start_DMA(

&hAdc[iAdc],

(uint32_t*) sampleBuffer[iAdc].samples[0],

_countof(sampleBuffer[iAdc].samples)

);

assert(result == HAL_OK);

Thanks,

Bill

1 ACCEPTED SOLUTION

Accepted Solutions

I don't understand the Cube/HAL gobbledygook, but maybe you want to read the Using the DMA subchapter of ADC chapter in RM, concentrating on the description of function of ADC_CR2.DDS bit. Note, that there's also a DDS bit in ADC_CCR, for multi-ADC mode.

JW

View solution in original post

2 REPLIES 2

I don't understand the Cube/HAL gobbledygook, but maybe you want to read the Using the DMA subchapter of ADC chapter in RM, concentrating on the description of function of ADC_CR2.DDS bit. Note, that there's also a DDS bit in ADC_CCR, for multi-ADC mode.

JW

Bill Finger
Associate III

Jan,

That was exactly it. I had spent hours debugging the DMA part of the code, without realizing the DDS bit misset in the ADC configuration section. Thank you.

Regards,

Bill