Hallo,
ich besitze einen STM3210e-Eval board mit einem STM32F103ZG ARM
Prozessor und arbeite in der Keil Umgebung. Bin relativ ein Neuling in
dem Gebiet...
Ich benütze von meinem Board die 3xBNC Eingänge(ADC1,ADC2,ADC3) als
Input.
Alles funktioniert.
Jetzt wollte ich zusätzlich noch den Potentiometer ansprechen
Leider habe ich kein ADC4 gefunden....
Wie soll das gehen das ich mehr ADC benutzen kann als nur ADC1,ADC2,ADC3
in meiner Libary.
Hier sieht man ne Typische Konfiguration allgemein für die ADC und dann
für ADC1.
1 | void Config_ADC(GPIO_InitTypeDef *GPIO_InitStructure)
|
2 | {
|
3 | RCC_ADCCLKConfig(RCC_PCLK2_Div6); //clock for ADC ADCCLK = PCLK2/6 = 72/6 = 12MHz*/
|
4 |
|
5 | // enable ADC system clock
|
6 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_AFIO | RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2 | RCC_APB2Periph_ADC3, ENABLE);
|
7 |
|
8 | /* Configure PC.01, PC.02 and PC.03 (ADC Channel 11, ADC Channel 12, ADC Channel 13) as analog input */
|
9 | GPIO_InitStructure->GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 ; // PC.01, PC.02 and PC.03
|
10 | GPIO_InitStructure->GPIO_Mode = GPIO_Mode_AIN; // Input-Mode
|
11 | GPIO_InitStructure->GPIO_Speed = GPIO_Speed_50MHz; // Speed of port
|
12 | GPIO_Init(GPIOC, GPIO_InitStructure); // apply configuration on PortC
|
13 |
|
14 | }
|
15 |
|
16 |
|
17 | void ADC1_Configuration(ADC_InitTypeDef *ADC_InitStructure)
|
18 | {
|
19 | ADC_InitStructure->ADC_ContinuousConvMode = ENABLE; //ster next convert automatically
|
20 | ADC_InitStructure->ADC_DataAlign = ADC_DataAlign_Right; //put left/right adjusted in register
|
21 | ADC_InitStructure->ADC_ExternalTrigConv = ADC_ExternalTrigConv_None; //choose which extern signal should start convert
|
22 | ADC_InitStructure->ADC_Mode = ADC_Mode_Independent;
|
23 | ADC_InitStructure->ADC_NbrOfChannel = 1;
|
24 | ADC_InitStructure->ADC_ScanConvMode = DISABLE;
|
25 |
|
26 | ADC_RegularChannelConfig(ADC1, ADC_Channel_11, 1, ADC_SampleTime_28Cycles5); //ADC_SampleTime_1Cycles5
|
27 | ADC_Init(ADC1, ADC_InitStructure); //set config of ADC1
|
28 |
|
29 | ADC_Cmd(ADC1, ENABLE); //enable ADC1
|
30 |
|
31 | }
|