AnsweredAssumed Answered

Read ADC Channel by Channel with hal

Question asked by khastar.mehdi on Sep 7, 2016
Latest reply on Sep 10, 2016 by khastar.mehdi
hello every one.

i want to run and use ADC on STM32f103.
i can read the analog value from ADC_1 and channel_0 in single mode.
but when i configure  ADC_1 and channel_0 ,channel_1 , channel_2 i can just read the 
analog value from channel_0.
how can i read ADC channel by channel which conflict does not occur?

//this is my main loop code.
int main(void)
{

  HAL_Init();

  SystemClock_Config();
  MX_GPIO_Init();
  MX_ADC1_Init();
  MX_CAN_Init();

  HAL_ADC_Start(&hadc1);
     
  while (1)
  {
    HAL_ADC_Start(&hadc1);

    if(HAL_ADC_GetValue(&hadc1) ==0)
{HAL_GPIO_WritePin(GPIOC,GPIO_PIN_6,GPIO_PIN_SET);HAL_GPIO_WritePin(GPIOC,GPIO_PIN_7,GPIO_PIN_RESET);}
          if(HAL_ADC_GetValue(&hadc1) !=0){HAL_GPIO_WritePin(GPIOC,GPIO_PIN_6,GPIO_PIN_RESET);HAL_GPIO_WritePin(GPIOC,GPIO_PIN_7,GPIO_PIN_SET);}
               
  }

}
  

Outcomes