今天把stm32的dma配置成 DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToMemory;
结果从lcd上读回来的数据是乱的!!调了好久都不知道是什么原因~
有哪位高手调过类似的程序,就来指点指点我吧!!
顺便问一下:MemoryToMemory是双向模式,那怎么确定数据的走向呢?
附stm32f4_dma的配置函数:
//STM32F4XX_DMA传输配置
static void dmaRead(u16* dst ,u16 size)
{
DMA_InitTypeDef DMA_InitStructure;
DMA_Cmd(DMA2_Stream0, DISABLE);
//RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
DMA_DeInit(DMA2_Stream0);
while (DMA_GetCmdStatus(DMA2_Stream0) != DISABLE);
//配置DMA流
DMA_InitStructure.DMA_Channel = DMA_Channel_0;
DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)(0X60000000); //
DMA_InitStructure.DMA_Memory0BaseAddr = (u32)dst;
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToMemory;
DMA_InitStructure.DMA_BufferSize = size; /* assert_param(0~64K) */
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Normal;//正常模式
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA2_Stream0, &DMA_InitStructure);
DMA_Cmd(DMA2_Stream0, ENABLE);
while ((DMA_GetCmdStatus(DMA2_Stream0) != ENABLE));
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
请教原子哥,f4系列dma理由DMA_GetCmdStatus()函数,想移植到f1系列,没有这个函数。是否可以省去,还是需要其它函数代替?谢谢!
一周热门 更多>