當前位置: 首頁>>代碼示例>>C++>>正文


C++ ADC_DMACmd函數代碼示例

本文整理匯總了C++中ADC_DMACmd函數的典型用法代碼示例。如果您正苦於以下問題:C++ ADC_DMACmd函數的具體用法?C++ ADC_DMACmd怎麽用?C++ ADC_DMACmd使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ADC_DMACmd函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: AdcStartPre34

static void AdcStartPre34()
{
	DMA_InitTypeDef DMA_InitStructure;
	DMA_DeInit(DMA2_Channel5);
	DMA_DeInit(DMA2_Channel2);

    DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC3->DR;
    DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&g_resultBuffer[0];
    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
    DMA_InitStructure.DMA_BufferSize = g_ResultBufferSize;
    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(DMA2_Channel5, &DMA_InitStructure);
    DMA_Cmd(DMA2_Channel5, ENABLE);
    DMA_ITConfig(DMA2_Channel5, DMA_IT_TC, ENABLE);
	DMA_SetCurrDataCounter(DMA2_Channel5, 0);

    DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC4->DR;
    DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&g_resultBuffer[g_ResultBufferSize/2];
    DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
    DMA_InitStructure.DMA_BufferSize = g_ResultBufferSize;
    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(DMA2_Channel2, &DMA_InitStructure);
    DMA_Cmd(DMA2_Channel2, ENABLE);
    DMA_ITConfig(DMA2_Channel2, DMA_IT_TC, ENABLE);
	DMA_SetCurrDataCounter(DMA2_Channel2, 0);

	uint8_t sample_ticks = DacSampleTicks()<72?ADC_SampleTime_7Cycles5:ADC_SampleTime_19Cycles5;
	//uint8_t sample_ticks = ADC_SampleTime_601Cycles5;
	ADC_RegularChannelConfig(ADC3, ADC_Channel_1/*PB1*/, 1, sample_ticks);
	ADC_RegularChannelConfig(ADC4, ADC_Channel_1/*PE14*/, 1, sample_ticks);

	ADC_Cmd(ADC3, ENABLE);
	ADC_Cmd(ADC4, ENABLE);
	ADC_DMACmd(ADC3, ENABLE);
	ADC_DMACmd(ADC4, ENABLE);
	g_adcStatus = 1;
	g_adc_cycles = 0;
}
開發者ID:balmerdx,項目名稱:rlc-meter-balmer,代碼行數:52,代碼來源:adc.c

示例2: gather_adc_values

void gather_adc_values(void)
{
    static uint8_t last_step = 0;
    // TIM1 CC4 occuer
    adc_buffer_for_mosfet_test[126] = DMA1_Channel1->CNDTR;
    TP3_SET;
    ADC_StopOfConversion(ADC1);
    ADC_DMACmd(ADC1, DISABLE);
    // reset the DMA
    DMA_Cmd(DMA1_Channel1, DISABLE);
    //DMA_DeInit(DMA1_Channel1);
    
    DMA_ClearFlag(DMA1_FLAG_GL1);

//     DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC1_DR_Address;
//     DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)adc_buffer_for_mosfet_test;
//     DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
//     DMA_InitStructure.DMA_BufferSize = 25;
//     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);
    DMA1_Channel1->CNDTR = 50;
    
    adc_buffer_for_mosfet_test[127] = ADC1->DR;
    DMA_Cmd(DMA1_Channel1, ENABLE);
    ADC_DMACmd(ADC1, ENABLE);
    
    ADC_StartOfConversion(ADC1);
    adc_buffer_for_mosfet_test[127] = DMA1_Channel1->CNDTR;
    
    if(last_step == mosfet_test_step){
        if(mosfet_test_step == 1){
            adc_buffer_for_mosfet_test[50] = adc_buffer_for_mosfet_test[0];
            adc_buffer_for_mosfet_test[51] = adc_buffer_for_mosfet_test[1];
            adc_buffer_for_mosfet_test[52] = adc_buffer_for_mosfet_test[2];
        }else{
            adc_buffer_for_mosfet_test[100] = adc_buffer_for_mosfet_test[0];
            adc_buffer_for_mosfet_test[101] = adc_buffer_for_mosfet_test[1];
            adc_buffer_for_mosfet_test[102] = adc_buffer_for_mosfet_test[2];
        }
    }
    last_step = mosfet_test_step;
    TP3_RESET;
}
開發者ID:Paolo-Maffei,項目名稱:lxyppc-tetrix,代碼行數:49,代碼來源:bldc.c

示例3: set_task_adc

void set_task_adc(struct signal* psig, struct head_data_adc* phadc) {
	if(pb_adc == NULL || !check_buffer_is_free(pb_adc)) 
		pb_adc = alloc_buf(SIZE_BIG_BUFFER);
	init_header_buffer_adc(pb_adc, sizeof(struct head_data_adc) + SIZE_BIG_BUFFER * sizeof(uint16_t), phadc);
	DMA_SetCurrDataCounter(DMA2_Stream0, NUMBER_SAMPL_ADC);
	DMA2_Stream0->M0AR = (uint32_t)((char*) pb_adc->pbuf + sizeof(struct head) + sizeof(struct head_data_adc));
	TIM3->ARR = psig->arr_adc;
	TIM_PrescalerConfig(TIM3, psig->psc_adc, TIM_PSCReloadMode_Update);
	/*Refill register TIM1CCR1*/
	TIM3->EGR |= 0x0001;
	DMA_Cmd(DMA2_Stream0, ENABLE);
	ADC_Cmd(ADC1, ENABLE);	
  ADC_DMACmd(ADC1, DISABLE);
	ADC_DMACmd(ADC1, ENABLE);
}
開發者ID:korrav,項目名稱:emmiter_slave,代碼行數:15,代碼來源:ADC_control.c

示例4: config_driver_adc_1

static void config_driver_adc_1(void)
{
    ADC_InitTypeDef ADC_InitStructure;

    ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
    ADC_InitStructure.ADC_ScanConvMode = DISABLE;
    ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
    ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
    ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1;
    ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
    ADC_InitStructure.ADC_NbrOfConversion = 1;
    ADC_Init(ADC1, &ADC_InitStructure);

    ADC_CommonInitTypeDef ADC_CommonInitStructure;

    ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
    ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div8;
    ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
    ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_20Cycles;
    ADC_CommonInit(&ADC_CommonInitStructure);

    ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 1, ADC_SampleTime_480Cycles);
    ADC_DMARequestAfterLastTransferCmd(ADC1, ENABLE);
    ADC_DMACmd(ADC1, ENABLE);
    ADC_Cmd(ADC1, ENABLE);

    ADC_SoftwareStartConv(ADC1);
}
開發者ID:glocklueng,項目名稱:ESP8266-STM32F4Discovery,代碼行數:28,代碼來源:adc_1.c

示例5: main

int main(void)
{
  //Initial Set-up of: SPI, USB, TIM2, and ADC
  SysInit();
  LMP_SPI_Init();                       
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);
  InitTIM2();
  startUSBOTG();
  ADC3_CH2_DMA_Config();
  TIM_ITConfig(TIM4, TIM_IT_Update, ENABLE);
  TIM_ITConfig(TIM4, TIM_IT_CC1, ENABLE);
  
  ADC_DMACmd(ADC3, ENABLE);
  //Main Loop: Transmit ADC result to PC
  while (1)
  {
    //Convert array elements in 1000 element array to 8 bit words and store in 
    //2000 element array
    for (int i=0; i<2000; i++)
      {
        if (i%2 == 0) adc3ch2_16bit[i] = (adc3ch2[i/2] >> 8);
        else adc3ch2_16bit[i] = (adc3ch2[i/2]);
      }
   //Output 2000 element array of ADC results over USB VCP Data line   
   for (int i=0; i < 2000; i++) VCP_DataTx (&adc3ch2_16bit[i],0);
  }
開發者ID:philipleaning,項目名稱:Gesture-Recognition,代碼行數:26,代碼來源:main+(05-07-12).c

示例6: IRsensor1_Init

void IRsensor1_Init(IRsensor * IRsensor){

  
  
  if(IRsensor!=NULL)
{ RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 , ENABLE);
         IRsensor->state1=1;
         Init_ADC_Common();  
         Init_DMA(); 
        
       RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
        
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 ;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
        GPIO_Init(GPIOC, &GPIO_InitStructure);

        ADC_Init(ADC1, &ADC_InitStructure);
        ADC_RegularChannelConfig(ADC1, ADC_Channel_12, 1, ADC_SampleTime_3Cycles);
       
        ADC_DMACmd(ADC1, ENABLE);
        ADC_Cmd(ADC1, ENABLE);
        ADC_SoftwareStartConv(ADC1);

  }
  
}
開發者ID:semikos,項目名稱:LineFollowerStm32F4,代碼行數:27,代碼來源:IRsensor.c

示例7: USART1_IRQHandler

/*******************************************************************************
* Function Name  : USART1_IRQHandler
* Description    : This function handles USART1 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void USART1_IRQHandler(void)
{	

	USART_ClearITPendingBit(USART1, USART_IT_RXNE);
	
   if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
   {
	   	Rx_Buffer[data]=USART_ReceiveData(USART1);
			
		Usart_Putnum(Rx_Buffer[data]);

		if(Rx_Buffer[data]==1){
			/* 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));
		 
		    /* Start ADC1 Software Conversion */ 
		    ADC_SoftwareStartConvCmd(ADC1, ENABLE);
		}

		else if(Rx_Buffer[data]==2)
			 ADC_Cmd(ADC1, DISABLE);
		else if(Rx_Buffer[data]==3)
		Usart_Putnum(TIM_GetCounter(TIM4));
		
	
   }

   
	//{	
		//Rx_Buffer[data]=data;
		//data++;
		//USART_ClearITPendingBit(USART1, USART_IT_RXNE);
		/*Rx_Buffer[data]=USART_ReceiveData(USART1);
		
		Usart_Putnum(Rx_Buffer[data]);
		data++;*/
		/*
		if(Rx_Buffer[data]==1)
		Usart_Putnum(10);
		else if(Rx_Buffer[data]==2)
		Usart_Putnum(20);
		*/
	
    
	
	
}
開發者ID:JinhoAndyPark,項目名稱:ARM,代碼行數:67,代碼來源:stm32f10x_it.c

示例8: sensor_init

void sensor_init(void)
{
    // 0. Run clocks
    RCC_AHBPeriphClockCmd(SENSORS_DMA_RCC, ENABLE);
    RCC_APB2PeriphClockCmd(SENSORS_ADC_RCC, ENABLE);

    // 1. Init ADC
    ADC_Init(SENSORS_ADC, &_adc);

    // 2. Init DMA for writing measures directly to array
    DMA_Init(SENSORS_DMA, &_dma); // SENSORS_ADC is on DMA1 channel 1

    // 3. Setup SENSORS_ADC to send DMA requests
    ADC_DMACmd(SENSORS_ADC, ENABLE);

    // 4. Enable DMA
    DMA_Cmd(SENSORS_DMA, ENABLE);

    // 5. Enable ADC
    ADC_Cmd(SENSORS_ADC, ENABLE);

    // 6. Calibrate ADC
    ADC_ResetCalibration(SENSORS_ADC);
    while(ADC_GetResetCalibrationStatus(SENSORS_ADC));;;

    ADC_StartCalibration(SENSORS_ADC);
    while(ADC_GetCalibrationStatus(SENSORS_ADC));;;
}
開發者ID:webconn,項目名稱:CereMotor,代碼行數:28,代碼來源:sensors.c

示例9: __ADC_Init

static void __ADC_Init(void)
{
	ADC_InitTypeDef ADC_InitStructure;
	
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
	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 = (USE_ADC_PB0 + USE_ADC_PB1 + USE_ADC_PA4 + USE_ADC_PC0); //Change
	ADC_Init(ADC1, &ADC_InitStructure);
	#if (USE_ADC_PB0 == 1)
	ADC_RegularChannelConfig(ADC1, ADC_Channel_8, 1, ADC_SampleTime_55Cycles5);
	#endif
	#if (USE_ADC_PB1 == 1)
	ADC_RegularChannelConfig(ADC1, ADC_Channel_9, 2, ADC_SampleTime_55Cycles5);
	#endif
	#if (USE_ADC_PA4 == 1)
	ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 3, ADC_SampleTime_55Cycles5);
	#endif
	#if (USE_ADC_PC0 == 1)
	ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 4, ADC_SampleTime_55Cycles5);
	#endif
	ADC_DMACmd(ADC1, ENABLE);
	ADC_Cmd(ADC1, ENABLE);
	ADC_ResetCalibration(ADC1);
	while(ADC_GetResetCalibrationStatus(ADC1));
	ADC_StartCalibration(ADC1);
	while(ADC_GetCalibrationStatus(ADC1));
	ADC_SoftwareStartConvCmd(ADC1, ENABLE);
}
開發者ID:NguyenTrongThinh,項目名稱:HapticDevice,代碼行數:32,代碼來源:AMES_ACS712.c

示例10: Adc1_Multi_Init

//初始化ADC1
//這裏采用多通道連續采樣,並用DMA1的通道傳送
//我們默認將開啟通道4~7
//相應管腳PA4~7
void Adc1_Multi_Init(void)
{ 	
	ADC_InitTypeDef ADC_InitStructure; 
	GPIO_InitTypeDef GPIO_InitStructure;

	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |RCC_APB2Periph_ADC1	, ENABLE );	  //使能ADC1通道時鍾
 

	RCC_ADCCLKConfig(RCC_PCLK2_Div6);   //設置ADC分頻因子6 72M/6=12,ADC最大時間不能超過14M

	//PA1 作為模擬通道輸入引腳
	GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7;
	GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;		//模擬輸入引腳
	GPIO_Init(GPIOA, &GPIO_InitStructure);	

	ADC_DeInit(ADC1);  //複位ADC1,將外設 ADC1 的全部寄存器重設為缺省值

	ADC_InitStructure.ADC_Mode = ADC_Mode_RegSimult;	//ADC工作模式:ADC1同步規則組模式
	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數據右對齊
	ADC_InitStructure.ADC_NbrOfChannel = 4;	//順序進行規則轉換的ADC通道的數目
	ADC_Init(ADC1, &ADC_InitStructure);	//根據ADC_InitStruct中指定的參數初始化外設ADCx的寄存器   

	ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 1, ADC_SampleTime_239Cycles5 );
	ADC_RegularChannelConfig(ADC1, ADC_Channel_5, 2, ADC_SampleTime_239Cycles5 );
	ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 3, ADC_SampleTime_239Cycles5 );
	ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 4, ADC_SampleTime_239Cycles5 );

	// 開啟ADC的DMA支持(要實現DMA功能,還需獨立配置DMA通道等參數)
	ADC_DMACmd(ADC1, ENABLE);
}	
開發者ID:devinzhang91,項目名稱:Health-Box,代碼行數:37,代碼來源:adc1.c

示例11: Accel_ADC_Configuration

/**
 * @brief Initializes the ADC used by the Accelerometer.
 * @retval None
 */
void Accel_ADC_Configuration() {
  ADC_InitTypeDef ADC_InitStructure;

  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 = 3;
  ADC_Init(ADC1, &ADC_InitStructure);

  /* ADC1 regular channel 10, 11, 12 configuration */ 
  ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 1, ADC_SampleTime_55Cycles5);
  ADC_RegularChannelConfig(ADC1, ADC_Channel_11, 2, ADC_SampleTime_55Cycles5);
  ADC_RegularChannelConfig(ADC1, ADC_Channel_12, 3, 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));
     
  /* Start ADC1 Software Conversion */ 
  ADC_SoftwareStartConvCmd(ADC1, ENABLE);
}
開發者ID:zwasson,項目名稱:project-blox,代碼行數:39,代碼來源:blox_accel.c

示例12: main

/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
void main(void)
{
  /* CLK configuration -------------------------------------------*/
  CLK_Config(); 

  /* ADC configuration -------------------------------------------*/
  ADC_Config(); 

  /* DMA configuration -------------------------------------------*/
  DMA_Config(); 

  /* TIM1 configuration -------------------------------------------*/
  TIM1_Config(); 

  /* Enable ADC1 DMA requests*/
  ADC_DMACmd(ADC1, ENABLE);

  /* Enable TIM1 DMA requests*/
  TIM1_DMACmd(TIM1_DMASource_Update, ENABLE);

  /* Start ADC1 Conversion using Software trigger*/
  ADC_SoftwareStartConv(ADC1);

  while (1)
  {}
}
開發者ID:avr-master,項目名稱:Healty_Beck,代碼行數:31,代碼來源:main.c

示例13: ADC1_Config

void ADC1_Config(void)
{
	ADC_InitTypeDef ADC_InitStructure;
	
	ADC_DeInit(ADC1);  //將外設 ADC1 的全部寄存器重設為缺省值
	
	/* ADC1 configuration ------------------------------------------------------*/
	ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;	//ADC1獨立工作模式
	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數據右對齊
	ADC_InitStructure.ADC_NbrOfChannel = 2;	//順序進行規則轉換的ADC通道的數目
	ADC_Init(ADC1, &ADC_InitStructure);	//根據ADC_InitStruct中指定的參數初始化外設ADCx的寄存器
	ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_239Cycles5 );	//ADC1,ADC通道3,規則采樣順序值為1,采樣時間為239.5周期	
	ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 2, ADC_SampleTime_239Cycles5);  
	ADC_DMACmd(ADC1, ENABLE);//使能ADC1模塊DMA
	/* Enable ADC1 */
	ADC_Cmd(ADC1, ENABLE);	//使能指定的ADC1
	/* Enable ADC1 reset calibaration register */   
	ADC_ResetCalibration(ADC1);	//重置指定的ADC1的校準寄存器
	/* Check the end of ADC1 reset calibration register */
	while(ADC_GetResetCalibrationStatus(ADC1));	//獲取ADC1重置校準寄存器的狀態,設置狀態則等待
	/* Start ADC1 calibaration */
	ADC_StartCalibration(ADC1);		//開始指定ADC1的校準狀態
	/* Check the end of ADC1 calibration */
	while(ADC_GetCalibrationStatus(ADC1));		//獲取指定ADC1的校準程序,設置狀態則等待
	/* Start ADC1 Software Conversion */ 
	ADC_SoftwareStartConvCmd(ADC1, ENABLE);		//使能指定的ADC1的軟件轉換啟動功能
}
開發者ID:andyzhao365,項目名稱:GuodianBeijingGuangyuACIntoDCDetectionDevice,代碼行數:30,代碼來源:adc.c

示例14: ADC_Configuration

/**
  * @brief  Configures the ADC.
  * @param  None
  * @retval None
  */
void ADC_Configuration(void)
{
	ADC_InitTypeDef ADC_InitStructure; // Structure to initialize the ADC

	// Configure ADC1 on channel 1
	ADC_InitStructure.ADC_Mode = 								ADC_Mode_Independent;
	ADC_InitStructure.ADC_ScanConvMode = 				DISABLE; // One channel only
	ADC_InitStructure.ADC_ContinuousConvMode = 	DISABLE; // Conversion on PWM rising edge only
	ADC_InitStructure.ADC_ExternalTrigConv = 		ADC_ExternalTrigConv_T1_CC1; // Timer 1 CC1
	ADC_InitStructure.ADC_DataAlign = 					ADC_DataAlign_Right;
	ADC_InitStructure.ADC_NbrOfChannel = 				1;

	// Initialise and enable ADC1
	ADC_DeInit( ADC1 ); //Set ADC registers to default values
	ADC_Init( ADC1, &ADC_InitStructure ); 
	ADC_RegularChannelConfig( ADC1, ADC_Channel_10, 1, ADC_SampleTime_71Cycles5);
	
	// Start transferts
  ADC_ExternalTrigConvCmd( ADC1, ENABLE ); // Enable ADC1 external trigger
	ADC_DMACmd( ADC1, ENABLE ); //Enable ADC1 DMA
	ADC_Cmd( ADC1, ENABLE ); //Enable ADC1

  // Enable JEOC interrupt
  //ADC_ITConfig(ADC1, ADC_IT_JEOC, ENABLE);

	// Calibrate ADC1
	ADC_ResetCalibration( ADC1 );
	while ( ADC_GetResetCalibrationStatus(ADC1) ) {} //Check the end of ADC1 reset calibration register
	ADC_StartCalibration( ADC1 );
	while ( ADC_GetCalibrationStatus(ADC1) ) {} //Check the end of ADC1 calibration
}
開發者ID:yohan-m,項目名稱:STM32-embedded-reception,代碼行數:36,代碼來源:sampleAcquisition.c

示例15: ADC_Configuration

static void ADC_Configuration(void)
{
	ADC_InitTypeDef ADC_InitStructure;
	  /* Check that HSI oscillator is ready */
  while(RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);
  /* ADC1 configuration */
  ADC_InitStructure.ADC_ScanConvMode = ENABLE;
	ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
  ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
  ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_NbrOfConversion = ADC_CHANNEL_NUM;
  ADC_Init(ADC1, &ADC_InitStructure);

	// ADC_TempSensorVrefintCmd(ENABLE);
  /* ADC1 regular channel18 configuration */ 
  ADC_RegularChannelConfig(ADC1, ADC_Channel_18, 1, ADC_SampleTime_4Cycles);
  //ADC_RegularChannelConfig(ADC1, ADC_Channel_Vrefint, 2, ADC_SampleTime_4Cycles);

  /* Enable the request after last transfer for DMA Circular mode */
  //ADC_DMARequestAfterLastTransferCmd(ADC1, ENABLE);
  
  /* Enable ADC1 */
  ADC_Cmd(ADC1, ENABLE);
  
  /* Enable ADC1 DMA */
  ADC_DMACmd(ADC1, ENABLE);
  /* Wait until the ADC1 is ready */
  while(ADC_GetFlagStatus(ADC1, ADC_FLAG_ADONS) == RESET)
  {
		
		
  }
}
開發者ID:nongxiaoming,項目名稱:STM32L151_RTX,代碼行數:34,代碼來源:adc.c


注:本文中的ADC_DMACmd函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。