AnsweredAssumed Answered

Use ADC1's 2 Channel Problem

Question asked by EYIGEL.Levent on Aug 1, 2012
Latest reply on Aug 1, 2012 by baird.hal.001
uint16_t Read_OPTOLed_ADC1(void) 
{  
   ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1,    ADC_SampleTime_71Cycles5);
  
  ADC_SoftwareStartConvCmd(ADC1, ENABLE);
    
    while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET); // Get the conversion value 
   
    OptoLedArray = ADC_GetConversionValue(ADC1);
        
   // return ADC_GetConversionValue(ADC1);
}


uint16_t Read_TEMP_ADC1(void) 

  ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 1, ADC_SampleTime_71Cycles5);
   
  while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET); // Get the conversion value 
  
  TempArray = ADC_GetConversionValue(ADC1);  
  
 // return ADC_GetConversionValue(ADC1);
}


The ADC Configuration 
void ADC_Configuration (void)

  
  ADC_InitTypeDef ADC_InitStructure;
  GPIO_InitTypeDef GPIO_InitStructure;


  RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC| 
                         RCC_APB2Periph_ADC1, ENABLE);
  ///////////////////////////////////////////////////////////////////////////////
  //////////////////////////////////////////////////////////////////////////////
  
  /* Configure PC4 (ADC Channel 7) as analog input -------------------------*/
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
  GPIO_Init(GPIOA, &GPIO_InitStructure);


  /* Configure PA7 (ADC Channel 14) as analog input -------------------------*/
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
  GPIO_Init(GPIOC, &GPIO_InitStructure);
  
  
  /* ADC1 configuration ------------------------------------------------------*/
  ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
  ADC_InitStructure.ADC_ScanConvMode = ENABLE;
  ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
  ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
  ADC_InitStructure.ADC_NbrOfChannel = 2;
  ADC_Init(ADC1, &ADC_InitStructure);

  
  /* 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);
  
}
PC.4 is ADC Channel 14 , PA.7 ADC Channel 7 ( Stm32 C-Eval )
I want to see this channels'  ADC Values but i see the same values at the same time.
Do i mistake at the configuration or ReadADC Function ?

Outcomes