2016-06-23 07:01 AM
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
2016-06-23 08:27 AM
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.2016-06-23 08:41 AM
Gosh I am having a bad day.
Thank you that fixed it.