AnsweredAssumed Answered

adc problem

Question asked by Max on Aug 25, 2011
Latest reply on Aug 25, 2011 by brazov.ajeje
Hi all,
I'm trying to work with the ADC of the Discovery board but I've some problem.
At the end of my test I can only read something from an4 to an9.
There is no way to read the first 4 channel, from an0 to an3.
If I connect the pins from ain0 to ain3 to gnd or vcc then the value read is always a random value, the same that I have if I leave the pin floating.
Please help to find a solution......
Here below some lines of my code:

main:
          GPIO_DeInit(GPIOE);
          GPIO_DeInit(GPIOB);
          GPIO_Init(GPIOE, GPIO_PIN_6,           GPIO_MODE_IN_FL_NO_IT);          //ain9
          GPIO_Init(GPIOE, GPIO_PIN_7,           GPIO_MODE_IN_FL_NO_IT);          //ain8
          GPIO_Init(GPIOB, GPIO_PIN_ALL,      GPIO_MODE_IN_FL_NO_IT);           //ain0-ain7

          ADC1_DeInit();           
          ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS, 
                                   ADC1_CHANNEL_9, 
                                   ADC1_PRESSEL_FCPU_D2, 
                                   ADC1_EXTTRIG_TIM, 
                                   DISABLE, 
                                   ADC1_ALIGN_LEFT, 
                                   ADC1_SCHMITTTRIG_ALL, 
                                   DISABLE); 
          ADC1_ScanModeCmd(ENABLE); //ENABLE
          ADC1_ITConfig(ADC1_IT_EOCIE,ENABLE);
          ADC1_Cmd(ENABLE);
          ADC1_StartConversion();

ADC1_ISR:
          for(i=0; i<=9;i++)
               Conversion_Values[i] = ADC1_GetBufferValue(i);
          csr_temp = ADC1->CSR;
          csr_temp &= (uint8_t)~ADC1_IT_EOC;
          csr_temp |= (uint8_t)(ADC1_CHANNEL_9);
          ADC1->CSR = csr_temp;
          ADC1_StartConversion();

Outcomes