Skip to main content
aeolia_amha
Associate III
May 17, 2010
Question

ADC/DMA array setup and read

  • May 17, 2010
  • 16 replies
  • 3398 views
Posted on May 17, 2010 at 08:28

ADC/DMA array setup and read

    This topic has been closed for replies.

    16 replies

    aeolia_amha
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:51

    As a practice, I did almost exactly the same as your code (M. Rost) except that I used 2 analog inputs and used GPIO_SetBits when a certain condition is met. Your method of using array worked. I'm still studying on how to do the 2-d array and how to store the data. Do you suggest that I average the data then store it or sample every of them and store every of them? Thanks.

    aeolia_amha
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:51

    I read in the firmware library manual that it can only read from 0 to 3.6V adc values. For this, can I use u16 ADC_RegularConvertedValueTab[5]; and read the values with floating point accuracy? or it can only display 0,1,2 and 3 since u16 is unsigned integer. Any idea on how to implement using usart to display in hyperterminal. I will use this for checking if the ADC values are correct.

    raptorhal2
    Lead
    May 17, 2011
    Posted on May 17, 2011 at 13:51

    Look in the reference manual for your device. In the 105 manual it is Chapter 3 Pin Descriptions, Table 5 Pin Definitions.

    Cheers, Hal

    aeolia_amha
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:51

    How do you set the ADC channels, 

    GPIOC pin 4,ADCvalue[0]

    GPIOC pin 5, ADCvalue[1]

    GPIOA pin 3,ADCvalue[2],

      ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1, ADC_SampleTime_28Cycles5);

      ADC_RegularChannelConfig(ADC1, ADC_Channel_15, 2, ADC_SampleTime_28Cycles5);

        ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 3, ADC_SampleTime_28Cycles5);

    It works for GPIOC pins, 4 and 5. ADC channel 14 and 15, how do you setup the ADC channel for GPIOA input, how will you know what ADC channel is for the corresponding GPIOA input. 

    Does GPIOC pins correspond to channel=(pin number +10). For example GPIOC pin 4 is ADC channel 14 because 4+10=14. For A is it just channel=pin number, example GPIOA pin 3 is ADC channel 3. I'm confused because it doesn't work.

    Tesla DeLorean
    Guru
    May 17, 2011
    Posted on May 17, 2011 at 13:51

    You will have to scale the number, the 12-bit number represents 4096 states between 0 and Vref

    double Vadc, Vref = 3.3;

    u16 Sample;

    Vadc = (double)Sample * (Vref / 4096.0);
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    aeolia_amha
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:51

    Thanks. I've read it and the pins corresponding to the ADC channels are written there. I'm just confused why some ADC channel config doesn't work like channels 2,3,8,9.