Hi
Ich habe hier 2 Potentiometer an je einen ADC1 Channel angschlossen.
Poti1 hängt an ADC1_Ch1 und Poti2 an ADC1_Ch2. Nun will ich per
Multichannel Single Conversion die beiden Spannungen wandeln lassen.
Das Problem an meinen Code ist das ich nach der Wandlung immer nur den
Wert des Ch3 im Speicher habe.
Aus dem Datenblatt kann ich nicht genau erkennen wie ich an beide Werte
heran komme.
Ich wäre sehr erfreut über eine Antwort da ich schon den ganzen
vormittag damit verbringe.
MfG
R. Griesser
Ich gebe hier mal meinen Code an:
//ADC1 Initialisierung
void ADCInit(void)
{
//Enable ADC Clocks
RCC_ADCCLKConfig(RCC_PCLK2_Div2);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,ENABLE);
//Enable the GPIOA Clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
//NVIC ADC setup
NVIC_InitStructure.NVIC_IRQChannel = ADC1_2_IRQn ;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
//setup of ADC CH1 & CH3 pins
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_3;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
//ADC setup
ADC_StructInit(&ADC_InitStructure);
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 2;
ADC_Init(ADC1, &ADC_InitStructure);
//ADC Ch1 & CH3 configuration
ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 1,
ADC_SampleTime_13Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 2,
ADC_SampleTime_13Cycles5);
//ADC Interrupt config
ADC_ITConfig(ADC1,ADC_IT_EOC,ENABLE);
//Enable ADC1
ADC_Cmd(ADC1, ENABLE);
//Enable Reset Calibration Register
ADC_ResetCalibration(ADC1);
//wait while Reset Calibration Register
while(ADC_GetResetCalibrationStatus(ADC1));
//Start ADC Calibration
ADC_StartCalibration(ADC1);
//wait while end of calibration
while(ADC_GetCalibrationStatus(ADC1));
}
//ADC1 Interrupt
void ADC_IRQHandler(void)
{
//Clear Interrupt
ADC_ClearITPendingBit(ADC1, ADC_IT_EOC);
//Get ADC Conversion Values
adc_Buffer[adc_counter] = ADC_GetConversionValue(ADC1);
adc_counter++;
}
//start befehl
//Start ADC conversion
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
Sehe ich das richtig, dass ich es per DMA lösen muss?
Hallo, könnten Sie bitte den Programmcode posten, da ich momentan mit einem ähnlichen Problem zu kämpfen habe und einfach nicht weiterkomme...
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.