求助 stm32是不是不能用DMA从adc数据寄存器里直接传到一个数组里
时间:10-02
整理:3721RD
点击:
这是配置源码:
u32 ADC_DataBuff[size];
volatile u32 ADC_Data;
void DMA_Config()
{
DMA_InitTypeDef DMA_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1,ENABLE);
DMA_DeInit(DMA1_Channel1);
DMA_InitStructure.DMA_PeripheralBaseAddr=ADC1_DR_Address;
DMA_InitStructure.DMA_MemoryBaseAddr=(u32)&ADC_DataBuff;
DMA_InitStructure.DMA_DIR=DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize=size;
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_M2M=DMA_M2M_Disable;
DMA_Init(DMA1_Channel1,&DMA_InitStructure);
DMA_Cmd(DMA1_Channel1,ENABLE);
}
main.c
#include "dma.h"
extern volatile u32 ADC_Data;
extern u32 ADC_DataBuff[size];
int main(void)
{
int temp,i;
delay_init();
NVIC_Configuration();
DMA_Config();
LCD_Init();
TIM3_Int_Init(1000,36000);
Adc_Init();
LCD_Clear(RED);
LCD_Fill(10,10,100,100,GBLUE);
LCD_DrawLine(20, 100, 20, 20);
for(i=0;i<size;i++)
{
temp=ADC_DataBuff;
LCD_ShowNum(200,200,temp,6,16);
}
只是贴出部分代码 求大虾
是可以的,v10 手册上面有