Gast
#2754922
Hallo,
ich arbeite mit einem STM32F103RBT6 und möchte 6 Analogeingänge
einlesen.
Problem 1 lässt sich wie folgt beschreiben:
PC.2 lässt sich nicht einlesen. Wert = 0 obwohl ein Signal am PIN laut
Oszi. anliegt. Hab ich evtl. irgendwo einen Copy+Paste Fehler eingebaut?
Problem 2:
PC5 liefert einen irritierenden Wert. Dieser erscheint ohne und mit
anliegendem Signal eim Eingang!
Bei Auskommentieren des ADC-Textes verschiebt sich dieser irritierende
Wert auf PC4!!
Vorher hatten PC3 und PC4 den Wert 0 oder den des anliegenden Signals
(Wieder mit dem Oszi nachgemessen).
Scheint mir dann doch in die Richtung eines Softwareproblems zu gehen.
Problem 3:
PC0-1 liefern ohne anliegendes Signal viel zu hohe Werte. Bei
anliegendem Signal arbeitet der ADC aber korrekt.
-----------
Könnte jemand mal über den Code gucken? Vermute doch starkt das es ein
Softwareproblem ist da 4 von 6 Eingängen ja korrekt eingelesen werden
bei anliegendem Signal! Hoffe es ist alles vorhanden und ich habe keinen
Code vergessen. Schöne Grüße, Christopher!
---------------------------------------------------------------
void ADC_Configuration(void)
{
ADC_InitTypeDef ADC_InitStructure;
/* ADC1 configuration */
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(ADC1, &ADC_InitStructure);
/* Enable ADC1 DMA */
//ADC_DMACmd(ADC1, ENABLE);
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);
/* Enable ADC1 reset calibaration register */
ADC_ResetCalibration(ADC1);
/* Check the end of ADC1 reset calibration register */
while(ADC_GetResetCalibrationStatus(ADC1));
/* Start ADC1 calibaration */
ADC_StartCalibration(ADC1);
/* Check the end of ADC1 calibration */
while(ADC_GetCalibrationStatus(ADC1));
}
------------------------------------------------------------------
/* Configure PC.0, PC.1, PC.2 (ADC Channel10..12, as analog inputs */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOC, &GPIO_InitStructure);
/* Configure PC.3, PC.4, PC.5 (ADC Channel10..12, as analog inputs */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOC, &GPIO_InitStructure);
------------------------------------------------------------------
void GetAD_values(void)
{
//ADC1
ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 1,
ADC_SampleTime_55Cycles5); //PIN PC0
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
voltage0=ADC_GetConversionValue(ADC1);
Delay(5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_11, 1,
ADC_SampleTime_55Cycles5); //PIN PC1
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
voltage1=ADC_GetConversionValue(ADC1);
Delay(5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_12, 1,
ADC_SampleTime_55Cycles5); //PIN PC2
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
voltage2=ADC_GetConversionValue(ADC1);
Delay(5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_13, 1,
ADC_SampleTime_55Cycles5); //PIN PC3
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
voltage3=ADC_GetConversionValue(ADC1);
Delay(5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1,
ADC_SampleTime_55Cycles5); //PIN PC4
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
voltage4=ADC_GetConversionValue(ADC1);
Delay(5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_15, 1,
ADC_SampleTime_55Cycles5); //PIN PC5
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);
voltage5=ADC_GetConversionValue(ADC1);
Delay(5);
}