cancel
Showing results for 
Search instead for 
Did you mean: 

Nucleo-144 DMA Memory to Memory Transfer not working

bradleybare
Associate II
Posted on June 23, 2016 at 16:01

I am trying to configure the DMA2 using the registers and I cannot get the DMA to work.

I must be having a bad day because nothing seems to be working correctly. Here is my simple code that does not work

//GPIO clock is already enabled and GPIO is configured
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN;
//enable DMA2
GPIO_ResetOutput(GPIOA,GPIO_PIN_1); //GPIO OFF
uint32_t from = 0xffffffff;
uint32_t to = 0;
DMA2_Stream0->CR &= DMA_SxCR_EN;
while((DMA2_Stream0->CR & DMA_SxCR_EN) != 0)
;
//wait for DMA to turn off
DMA2_Stream0->CR = 0b00000000000000110101000010000000;
//set mem2mem, no increment, datasize as 32bit.
DMA2_Stream0->PAR = &from; //from address
DMA2_Stream0->M0AR = &to; //to address
DMA2_Stream0->NDTR = 1; //data to transfer
DMA2_Stream0->FCR &= ~0b11; //Lowest FIFO level
DMA2_Stream0->CR |= DMA_SxCR_EN; //Enable Stream.
DelayMilli(1000); //Delay to allow stream to transfer for test
if(to == from) //test the memory transfer was successful
{
GPIOSetOutput(GPIOA,GPIO_PIN1); //GPIO ON
}

Nothing ever happens. I am a lost puppy because the DMA should be simple but I am having nothing but problems. Thank you for any opinions
2 REPLIES 2
Posted on June 23, 2016 at 17:27

If you are checking memory locations that might change outside of normal program flow, then they should be defined as volatile.

Watch also that you don't transfer data in cached memory spaces, there is really no hardware here to maintain coherency.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
bradleybare
Associate II
Posted on June 23, 2016 at 17:41

Gosh I am having a bad day.

Thank you that fixed it.