不好意思 回复晚了 下面的是我的初始化代码 数据位是半字16位 void ADC1_Mode_Config(void) { DMA_InitTypeDef DMA_InitStructure; ADC_InitTypeDef ADC_InitStructure; GPIO_InitTypeDef GPIO_InitStructure; /* Enable DMA clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |RCC_APB2Periph_ADC1 , ENABLE ); //ʹÄÜADC1ͨµÀʱÖÓ //PA1 ×÷ΪģÄâͨµÀÊäÈëÒý½Å GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 |GPIO_Pin_1|GPIO_Pin_2; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; //Ä£ÄâÊäÈëÒý½Å GPIO_Init(GPIOA, &GPIO_InitStructure); /* DMA channel1 configuration */ DMA_DeInit(DMA1_Channel1); DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address; //ADCµØÖ· DMA_InitStructure.DMA_MemoryBaseAddr = (u32)&ADC_ConvertedValue;//ÄÚ´æµØÖ· DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC; 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; //Ñ»·´«Êä DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_M2M = DMA_M2M_Disable; DMA_Init(DMA1_Channel1, &DMA_InitStructure); /* Enable DMA channel1 */ DMA_Cmd(DMA1_Channel1, ENABLE); /* ADC1 configuration */ ADC_InitStructure.ADC_Mode = ADC_Mode_Independent; //¶ÀÁ¢ADCģʽ ADC_InitStructure.ADC_ScanConvMode = ENABLE ; //½ûֹɨÃèģʽ£¬É¨ÃèģʽÓÃÓÚ¶àͨµÀ²É¼¯ ADC_InitStructure.ADC_ContinuousConvMode = ENABLE; //¿ªÆôÁ¬Ðøת»»Ä£Ê½£¬¼´²»Í£µØ½øÐÐADCת»» ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; //²»Ê¹ÓÃÍⲿ´¥·¢×ª»» ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; //²É¼¯Êý¾ÝÓÒ¶ÔÆë ADC_InitStructure.ADC_NbrOfChannel = 3; //Ҫת»»µÄͨµÀÊýÄ¿1 ADC_Init(ADC1, &ADC_InitStructure); RCC_ADCCLKConfig(RCC_PCLK2_Div6); //ÉèÖÃADC·ÖƵÒò×Ó6 72M/6=12,ADC×î´óʱ¼ä²»Äܳ¬¹ý14M /*ÅäÖÃADC1µÄͨµÀ11Ϊ55. 5¸ö²ÉÑùÖÜÆÚ£¬ÐòÁÐΪ1 */ // ADC_RegularChannelConfig(ADC1, ADC_Channel_11, 1, ADC_SampleTime_55Cycles5); //ÉèÖÃÖ¸¶¨ADCµÄ¹æÔò×éͨµÀ£¬Ò»¸öÐòÁУ¬²ÉÑùʱ¼ä ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_239Cycles5 ); //ADC1,ADCͨµÀ,²ÉÑùʱ¼äΪ239.5ÖÜÆÚ ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 2, ADC_SampleTime_239Cycles5 ); ADC_RegularChannelConfig(ADC1, ADC_Channel_2, 3, ADC_SampleTime_239Cycles5 ); /* Enable ADC1 DMA */ ADC_DMACmd(ADC1, ENABLE); /* Enable ADC1 */ ADC_Cmd(ADC1, ENABLE); /*¸´Î»Ð£×¼¼Ä´æÆ÷ */ ADC_ResetCalibration(ADC1); /*µÈ´ýУ׼¼Ä´æÆ÷¸´Î»Íê³É */ while(ADC_GetResetCalibrationStatus(ADC1)); /* ADCУ׼ */ ADC_StartCalibration(ADC1); /* µÈ´ýУ׼Íê³É*/ while(ADC_GetCalibrationStatus(ADC1)); /* ÓÉÓÚûÓвÉÓÃÍⲿ´¥·¢£¬ËùÒÔʹÓÃÈí¼þ´¥·¢ADCת»» */ // ADC_SoftwareStartConvCmd(ADC1, ENABLE); }
所在话题
参与活动
-
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
线下 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
网络 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
网络 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
网络 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
线下 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
线下 2020-10-16