高中生
最后登录1970-1-1
在线时间 小时
注册时间2021-3-27
|
发表于 2021-6-23 10:48:39
|
显示全部楼层
地址递增的配置应该只有就是DMA_MemoryInc_Enable相关的吧,楼主有空可以帮忙看看我的DMA配置代码吗?希望传输的时候存储地址能更新,但一直是固定的,调了好久了,还是不知道问题在哪
- void dma_init(uint32_t ADCvalue_addr){
- //使能DMA总线时钟
- RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
- //channel0 stream0
- DMA_DeInit(DMA2_Stream0); //先失能。将DMA所有寄存器复位为未修改状态
- while(DMA_GetCmdStatus(DMA2_Stream0) != DISABLE){ //确保DMA数据流复位完成
- }
-
- DMA_InitTypeDef DMA_InitStructure;
- DMA_InitStructure.DMA_Channel = DMA_Channel_0;
- DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_ADDRESS;
- DMA_InitStructure.DMA_Memory0BaseAddr = ADCvalue_addr; //ADCvalue_addr为j基地址
- DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
- DMA_InitStructure.DMA_BufferSize = 3;
- 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_Circular; //仿照例子用循环模式,传输完数据后,重新将BufferSize填满
- DMA_InitStructure.DMA_Priority = DMA_Priority_High;
- DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
- DMA_Init(DMA2_Stream0, &DMA_InitStructure);
- DMA_Cmd(DMA2_Stream0, ENABLE);
- }
复制代码
|
|