:如何将 在DMA 中多通道采样中准备指定数组中特定位置存ADC值 ? (如:ADC通道1 存放于RegularConvData_Tab[1],ADC通道2存放RegularConvData_Tab【2】,以此类推 程序如下: ADC_InitTypeDef ADC_InitStructure; DMA_InitTypeDef DMA_InitStructure; INT16U ADC_Raw_Value[ 14*ADC_Converted_len ]; //adc»ñÈ¡µÄÔʼÊý¾Ý INT16U ADC_ConvertedValue[14]; //¼ÆËãת»»ºÃµÄ×îÖÕÓû§Êý¾Ý __IO uint16_t RegularConvData_Tab[14]; void InitADC(void) { // configuration ADC /////////////////////////////////////////////////////////////// GPIO_InitTypeDef GPIO_InitStructure; DMA_InitTypeDef DMA_InitStructure; ADC_InitTypeDef ADC_InitStructure; NVIC_InitTypeDef NVIC_InitStruct; RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_3|GPIO_Pin_4 |GPIO_Pin_5; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(GPIOA, &GPIO_InitStructure); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE); GPIO_InitStructure.GPIO_Pin =GPIO_Pin_0| GPIO_Pin_1| GPIO_Pin_2| GPIO_Pin_4|GPIO_Pin_5; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(GPIOC, &GPIO_InitStructure); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; GPIO_Init(GPIOB, &GPIO_InitStructure); //NVIC_InitStruct.NVIC_IRQChannel = DMA1_Channel1_IRQn; // NVIC_InitStruct.NVIC_IRQChannelPriority = 2; //NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE; //NVIC_Init(&NVIC_InitStruct); RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 , ENABLE); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1 , ENABLE); ADC_DeInit(ADC1);//ADC»Ö¸´Ä¬ÈÏÉèÖà DMA_DeInit(DMA1_Channel1); /* DMA1 Channel1 Config */ DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC1_DR_Address;//ÍâÉèµØÖ· DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&ADC_Raw_Value;//ÄÚ´æµØÖ·RegularConvData_Tab DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;//ÍâÉè×÷ΪÊý¾Ý´«ÊäµÄÀ´Ô´ DMA_InitStructure.DMA_BufferSize = 14*ADC_Converted_len;// 12 DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;//ÍâÉèµØÖ·¼Ä´æÆ÷²»±ä DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;//ÄÚ´æµØÖ·¼Ä´æÆ÷²»±ä DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;//Êý¾Ý¿í¶ÈΪ16λ DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;//Êý¾Ý¿í¶ÈΪ16λ DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High;//DMA_PriorityÉ趨DMAͨµÀxµÄÈí¼þÓÅÏȼ¶ DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;//DMAͨµÀxûÓÐÉèÖÃΪÄÚ´æµ½ÄÚ´æ´«Êä DMA_Init(DMA1_Channel1, &DMA_InitStructure); DMA_Cmd(DMA1_Channel1, ENABLE);/* DMA1 Channel1 enable */ /*Enables the specified DMAy Channelx interrupts */ //DMA_ITConfig(DMA1_Channel1,DMA_IT_TC,ENABLE); /* ADC DMA request in circular mode */ ADC_DMARequestModeConfig(ADC1, ADC_DMAMode_Circular); /* Enable ADC_DMA */ ADC_DMACmd(ADC1, ENABLE); ADC_StructInit(&ADC_InitStructure);//³õʼ»¯ADC½á¹¹ ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;//12λ¾«¶È ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; //¹æ¶¨Ä£Ê½×°»»¹¤×÷ÔÚÁ¬Ðøģʽ ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None; ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;//Êý¾Ý¶ÔÆäΪÓÒ¶ÔÆë ADC_InitStructure.ADC_ScanDirection = ADC_ScanDirection_Backward; //ADCµÄɨÃè·½Ïò ADC_Init(ADC1, &ADC_InitStructure); //ADC_ChannelConfig(ADC1, ADC_Channel_1 , ADC_SampleTime_239_5Cycles); /* Convert the ADC1 Channel 11 with 239.5 Cycles as sampling time */ //ADC_ChannelConfig(ADC1, ADC_Channel_Vrefint ,ADC_SampleTime_239_5Cycles); //ADC_VrefintCmd(ENABLE); //ADC_ChannelConfig(ADC1, ADC_Channel_TempSensor ,ADC_SampleTime_239_5Cycles); //ADC_TempSensorCmd(ENABLE); //ADC_ChannelConfig(ADC1, ADC_Channel_Vbat ,ADC_SampleTime_239_5Cycles); //ADC_VbatCmd(ENABLE); ADC_ChannelConfig(ADC1, ADCGrp1I, ADC_SampleTime_28_5Cycles); //28.5 ADC_ChannelConfig(ADC1, ADCGrp1V , ADC_SampleTime_28_5Cycles); ADC_ChannelConfig(ADC1, ADCGrp1T, ADC_SampleTime_28_5Cycles); ADC_ChannelConfig(ADC1, ADCGrp2I, ADC_SampleTime_28_5Cycles); ADC_ChannelConfig(ADC1, ADCGrp2V , ADC_SampleTime_28_5Cycles); ADC_ChannelConfig(ADC1, ADCGrp2T, ADC_SampleTime_28_5Cycles); ADC_ChannelConfig(ADC1, ADCGrp3I, ADC_SampleTime_28_5Cycles); ADC_ChannelConfig(ADC1, ADCGrp3V , ADC_SampleTime_28_5Cycles); ADC_ChannelConfig(ADC1, ADCGrp3T, ADC_SampleTime_28_5Cycles); ADC_ChannelConfig(ADC1, ADCGrp4I, ADC_SampleTime_28_5Cycles); ADC_ChannelConfig(ADC1, ADCGrp4V , ADC_SampleTime_28_5Cycles); ADC_ChannelConfig(ADC1, ADCGrp4T, ADC_SampleTime_28_5Cycles); ADC_ChannelConfig(ADC1, ADC_Channel_TempSensor, ADC_SampleTime_28_5Cycles); ADC_TempSensorCmd(ENABLE); ADC_ChannelConfig(ADC1, ADC_Channel_Vrefint , ADC_SampleTime_28_5Cycles); ADC_VrefintCmd(ENABLE); ADC_GetCalibrationFactor(ADC1); /* ADC Calibration */ ADC_Cmd(ADC1, ENABLE); /* Enable ADCperipheral[PerIdx] */ while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_ADEN)); /* Wait the ADCEN falg */ ADC_StartOfConversion(ADC1); /* ADC1 regular Software Start Conv */ } |
【STM32F0开发日志/评测/笔记】+互补PWM波的产生
STM32F030 PB14和PB15无法输出PWM求助
【STM32F030探索套件】序列之五 外部中断
【STM32F0开发日志---二】+ucosii.2.92移植在STM32F030
上传个STM32F0+5110+内部温度传感器的菜鸟实例
【STM32F030探索套件使用问题】STM32F030 SPI方式驱动ST7565LCD失败
求一份STM32F051 I2C驱动LCD 12864的例程
STM32F0 M0 向结构体赋值进入HardFault异常
STM32F0 ADC-DMA方式采集2路数据时出现问题
STM32F030C8T6,TIM16定时慢很多问题?
RE:STM32F030R8 ADC采样DMA问题
RE:STM32F030R8 ADC采样DMA问题
RE:STM32F030R8 ADC采样DMA问题
RE:STM32F030R8 ADC采样DMA问题