AnsweredAssumed Answered

Multi ADC conversion

Question asked by waytae on Jan 21, 2013
Latest reply on Jan 22, 2013 by Clive One
Hi friends

I use this program to Read ADC1 Value connected to PC2 port of my "stm32f4discovery" card .

01./****************************************************************************************/
02.void ADC_setup(void)
03.{
04.    /* Enable ADC clock (This seems to be a duplicate statement) */
05.        RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
06.      RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
07.    /*********************************************************/
08.        /* Configure ADC Channel 12 pin as analog input */
09.        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
10.        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
11.        GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
12.        GPIO_Init(GPIOC, &GPIO_InitStructure);
13.    /*** ADC1 regular channel 12 configuration ***/
14.        ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
15.        ADC_InitStructure.ADC_ScanConvMode = DISABLE;
16.        ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
17.        ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
18.        ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
19.        ADC_InitStructure.ADC_NbrOfConversion = 1;
20.        ADC_Init(ADC1, &ADC_InitStructure);
21.        ADC_RegularChannelConfig(ADC1, ADC_Channel_12, 1, ADC_SampleTime_3Cycles);
22. 
23.    /* Enable ADC1 */
24.        ADC_Cmd(ADC1, ENABLE);
25.}
26./*Read potentiometer (voltage) value*/
27. 
28.int POTGetValue(void)
29.{
30.        ADC_SoftwareStartConv(ADC1);
31.        while(ADC_GetSoftwareStartConvStatus(ADC1));
32.        return ADC_GetConversionValue(ADC1);
33.}
34./****************************************************************************************/
35. 
36.int main(void)
37.{
38.    ADC_setup();
39. 
40.        int val1 = POTGetValue();
41. 
42.        puts(val1);
43.}

It works, Now i want to display many ADC conversion for example i want to connect 4 signal to 4 port PC0, PC1, PC2 AND PC3.

what are the modifications to do please ?

I found in datasheet that PC2 represent ADC_Channel_12 that's why i use it


And i use in ligne 19 one number of conversion

Thank you

Outcomes