DMA_DeInit(DMA1_Channel1);
DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address; // ADC DR address
DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&wADC_ConvertedValue; // memory
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; // ADC->DMA
DMA_InitStructure.DMA_BufferSize = 16;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; // only ADC DR
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; // 16 words memory
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord; // 16bits data
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord; // 16bits data
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; //
DMA_InitStructure.DMA_Priority = DMA_Priority_High; //
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; //
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
// Enable DMA1 channel1
DMA_Cmd(DMA1_Channel1, ENABLE);
// ADC1 configuration
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; // 独立
ADC_InitStructure.ADC_ScanConvMode = ENABLE; // 多通道
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; // 连续
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; // 软件触发
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; // 排列方式
ADC_InitStructure.ADC_NbrOfChannel = 16; // 16通道
ADC_Init(ADC1, &ADC_InitStructure);
// ADC1 regular channel configuration
ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 2, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_2, 3, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 4, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 5, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 6, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 7, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 8, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 9, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_9, 10, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 11, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_11, 12, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_12, 13, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_13, 14, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 15, ADC_SampleTime_55Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_15, 16, ADC_SampleTime_55Cycles5);
// Enable ADC1 DMA
ADC_DMACmd(ADC1, ENABLE);
// Enable ADC1
ADC_Cmd(ADC1, ENABLE);
// Enable ADC1 reset calibaration register
ADC_ResetCalibration(ADC1);
// Check the end of ADC1 reset calibration register
while(ADC_GetResetCalibrationStatus(ADC1));
// Start ADC1 calibaration
ADC_StartCalibration(ADC1);
// Check the end of ADC1 calibration
while(ADC_GetCalibrationStatus(ADC1));
这个是给的例程,结果是把16个数据一起放到16个地址里,且不断刷新
我导师的要求是1个通道,放置很多的数据,做成一个块,不知道可不可以实现? |
|