Hallo Forum, ich bin gerade dabei bei einem STM32F303 (64Pins) ADC Werte auszulesen. Für einen Wert ist das kein Problem. Was sich als Problem rausstellt, ist die zyklische Abfrage von ADC Werten von ADC1. Auf der Tutorialseite http://www.diller-technologies.de/stm32.html steht im Kapitel 13.3 beschrieben, wie man mehrere Kanäle auslesen kann. Dies funktioniert wie dargestellt leider nicht. Zum Beispiel kann ADC_InitStructure.ADC_ScanConvMode = ENABLE; nicht aufgerufen werden. (Laut AN3116 sollte es durch den Multichannel (scan) continuous conversion mode möglich sein das wie auf der Diller Seite zu lösen) Meine Fragen: 1) Gibt einen solchen Modus überhaupt noch? 2)Welchen Mode stelle ich ein, wenn ich die Kanäle des ADC1 abfragen will (ADC_Channel_6- ADC_Channel_9) Mode_Independent ist es laut stm32f30x_adc.h File nicht, weil dieser nicht explizit als ADC Multi ADC mode gekennzeichnet ist. Vielen Dank für euren Input.
Du hast einen Fehler in Zeile 42 gemacht. Im Ernst: Wie sollen wir Dir helfen, wenn wir Deinen Source Code nicht sehen?
1 | /* Configure the ADC clock */
|
2 | RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div2); |
3 | |
4 | /* Enable ADC1 clock */
|
5 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ADC12, ENABLE); |
6 | |
7 | |
8 | |
9 | /* Setup SysTick Timer for 1 µsec interrupts */
|
10 | if (SysTick_Config(SystemCoreClock / 10000)) |
11 | {
|
12 | /* Capture error */
|
13 | while (1) |
14 | {}
|
15 | }
|
16 | |
17 | /* ADC Channel configuration */
|
18 | /* GPIOC Periph clock enable */
|
19 | RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE); |
20 | |
21 | /* Configure ADC Channel7 as analog input */
|
22 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 ; |
23 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; |
24 | GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ; |
25 | GPIO_Init(GPIOC, &GPIO_InitStructure); |
26 | |
27 | |
28 | ADC_StructInit(&ADC_InitStructure); |
29 | |
30 | /* Calibration procedure */
|
31 | ADC_VoltageRegulatorCmd(ADC1, ENABLE); |
32 | |
33 | /* Insert delay equal to 10 µs */
|
34 | // Delay(10);
|
35 | |
36 | ADC_SelectCalibrationMode(ADC1, ADC_CalibrationMode_Single); |
37 | ADC_StartCalibration(ADC1); |
38 | |
39 | while(ADC_GetCalibrationStatus(ADC1) != RESET ); |
40 | calibration_value = ADC_GetCalibrationValue(ADC1); |
41 | |
42 | ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent; |
43 | /* ADC_CommonInitStructure.ADC_Clock = ADC_Clock_AsynClkMode;
|
44 | ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
|
45 | ADC_CommonInitStructure.ADC_DMAMode = ADC_DMAMode_OneShot;
|
46 | ADC_CommonInitStructure.ADC_TwoSamplingDelay = 9;*/
|
47 | |
48 | ADC_CommonInit(ADC1, &ADC_CommonInitStructure); |
49 | |
50 | ADC_InitStructure.ADC_ContinuousConvMode = ADC_ContinuousConvMode_Enable; |
51 | ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b; |
52 | ADC_InitStructure.ADC_ExternalTrigConvEvent = ADC_ExternalTrigConvEvent_0; |
53 | ADC_InitStructure.ADC_ExternalTrigEventEdge = ADC_ExternalTrigEventEdge_None; |
54 | ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right; |
55 | ADC_InitStructure.ADC_OverrunMode = ADC_OverrunMode_Disable; |
56 | ADC_InitStructure.ADC_AutoInjMode = ADC_AutoInjec_Disable; |
57 | ADC_InitStructure.ADC_NbrOfRegChannel = 2; |
58 | ADC_Init(ADC1, &ADC_InitStructure); |
59 | |
60 | /* ADC1 regular channel6 configuration */
|
61 | ADC_RegularChannelConfig(ADC1, ADC_Channel_6, 1, ADC_SampleTime_19Cycles5); |
62 | ADC_RegularChannelConfig(ADC1, ADC_Channel_7, 2, ADC_SampleTime_19Cycles5); |
63 | |
64 | /* Enable ADC1 */
|
65 | ADC_Cmd(ADC1, ENABLE); |
66 | |
67 | /* wait for ADRDY */
|
68 | while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_RDY)); |
69 | |
70 | /* Start ADC1 Software Conversion */
|
71 | ADC_StartConversion(ADC1); |
72 | |
73 | /* Infinite loop */
|
74 | while (1) |
75 | {
|
76 | /* Test EOC flag */
|
77 | while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET); |
78 | |
79 | /* Get ADC1 converted data */
|
80 | ADC1ConvertedValue =ADC_GetConversionValue(ADC1); |
81 | |
82 | /* Compute the voltage */
|
83 | ADC1ConvertedVoltage = (ADC1ConvertedValue *3000)/0xFFF; |
84 | |
85 | |
86 | |
87 | |
88 | }
|
89 | }
|
Hier ist der geforderte Code, allerdings geht es mir nicht darum das man sagt ja hier ist der Fehler sondern das ich ein allgemeines Verständnis für die Problematik bekomme, sonst schreibe ich in ein paar Wochen wieder.... Mir ist klar das hier der Teil nicht funktionieren kann. Allerdings zeigt mir der Debugger an das er die Variable nicht lesen kann.
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
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.