Forum: Mikrocontroller und Digitale Elektronik STM32F3 ADC Kalibrierungsproblem


von Andreas T. (skycurve)


Lesenswert?

Moin,

ich habe ein Problem mit der ADC Initialisierung.
Zum Einsatz kommt ein STM32F303CCT6. Alle vier ADCs werdem von TIM1 
getriggert, die ADC Ergebnisse werden von DMA verarbeitet.

Davor hatte ich den gleichen Code am STM32F3 Disco Board laufen, ohne 
Probleme. Jetzt auf meinem eigenen PCB bleibt die Initialisierung bei 
folgender Zeile hängen:
1
  while(ADC_GetCalibrationStatus(ADC1) != RESET );
2
  CalibrationValue[0] = ADC_GetCalibrationValue(ADC1);

Hier der Codeausschnitt
1
void ADC_Configuration(void)
2
{
3
    ADC_InitTypeDef        ADC_InitStructure;
4
    ADC_CommonInitTypeDef  ADC_CommonInitStructure;
5
  volatile int i;
6
7
  /* Configure the ADC clocks */
8
  RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div1);
9
  RCC_ADCCLKConfig(RCC_ADC34PLLCLK_Div1);
10
11
  /* Enable ADC1/2/3/4 clocks */
12
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ADC12 | RCC_AHBPeriph_ADC34, ENABLE);
13
14
  /* ADC GPIO configuration */
15
  ADC_GPIO_Configuration();
16
17
  /* ADC DMA Channel configuration */
18
  ADC12_DMA_Configuration();
19
  ADC34_DMA_Configuration();
20
21
  /* ADC Calibration procedure */
22
  ADC_VoltageRegulatorCmd(ADC1, ENABLE);
23
  ADC_VoltageRegulatorCmd(ADC2, ENABLE);
24
  ADC_VoltageRegulatorCmd(ADC3, ENABLE);
25
  ADC_VoltageRegulatorCmd(ADC4, ENABLE);
26
27
  /* Insert delay equal to 10 µs */
28
  //Delay(10);
29
    for(i=0; i<10000; i++);
30
31
  ADC_SelectCalibrationMode(ADC1, ADC_CalibrationMode_Single);
32
  ADC_StartCalibration(ADC1);
33
34
  ADC_SelectCalibrationMode(ADC2, ADC_CalibrationMode_Single);
35
  ADC_StartCalibration(ADC2);
36
37
  ADC_SelectCalibrationMode(ADC3, ADC_CalibrationMode_Single);
38
  ADC_StartCalibration(ADC3);
39
40
  ADC_SelectCalibrationMode(ADC4, ADC_CalibrationMode_Single);
41
  ADC_StartCalibration(ADC4);
42
43
  while(ADC_GetCalibrationStatus(ADC1) != RESET );
44
  CalibrationValue[0] = ADC_GetCalibrationValue(ADC1);
45
46
  while(ADC_GetCalibrationStatus(ADC2) != RESET );
47
  CalibrationValue[1] = ADC_GetCalibrationValue(ADC2);
48
49
  while(ADC_GetCalibrationStatus(ADC3) != RESET );
50
  CalibrationValue[2] = ADC_GetCalibrationValue(ADC3);
51
52
  while(ADC_GetCalibrationStatus(ADC4) != RESET );
53
  CalibrationValue[3] = ADC_GetCalibrationValue(ADC4);
54
55
  /* ADC Dual mode configuration */
56
  ADC_CommonInitStructure.ADC_Mode = ADC_Mode_RegSimul;
57
  ADC_CommonInitStructure.ADC_Clock = ADC_Clock_AsynClkMode;
58
  ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_1; // 12-bit
59
  ADC_CommonInitStructure.ADC_DMAMode = ADC_DMAMode_Circular;
60
  ADC_CommonInitStructure.ADC_TwoSamplingDelay = 10;
61
62
  ADC_CommonInit(ADC1, &ADC_CommonInitStructure);
63
  ADC_CommonInit(ADC3, &ADC_CommonInitStructure);
64
65
  /* */
66
  ADC_InitStructure.ADC_ContinuousConvMode = ADC_ContinuousConvMode_Disable; // Triggered
67
  ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
68
  ADC_InitStructure.ADC_ExternalTrigEventEdge = ADC_ExternalTrigEventEdge_RisingEdge;
69
  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
70
  ADC_InitStructure.ADC_OverrunMode = ADC_OverrunMode_Disable;
71
  ADC_InitStructure.ADC_AutoInjMode = ADC_AutoInjec_Disable;
72
  ADC_InitStructure.ADC_NbrOfRegChannel = 3;
73
74
  ADC_InitStructure.ADC_ExternalTrigConvEvent =
75
      ADC_ExternalTrigConvEvent_10; // Entspricht dem TRGO2 des TIM1
76
    //  ADC_ExternalTrigConvEvent_3; // ADC1/2 EXT3 TIM2_CC2
77
78
    ADC_Init(ADC1, &ADC_InitStructure);
79
  ADC_Init(ADC2, &ADC_InitStructure);
80
81
  ADC_InitStructure.ADC_ExternalTrigConvEvent =
82
      ADC_ExternalTrigConvEvent_10; // Entspricht dem TRGO2 des TIM1
83
     // ADC_ExternalTrigConvEvent_1; // ADC3/4 EXT1 TIM2_CC3
84
85
    ADC_Init(ADC3, &ADC_InitStructure);
86
  ADC_Init(ADC4, &ADC_InitStructure);
87
}

Habt ihr eine Idee woran das liegen könnte?

Gruß

von Andreas T. (skycurve)


Lesenswert?

Fehler gefunden. Code lief NICHT exakt genau so wie auf dem STM32F3 
Discoboard, weil ich auf meinem eigenen Board kein Quarz verbaut hatte.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.