2ADCs mit jeweils 2 Channels

Gast #3981220
Lesenswert?

Hallo erstmal,

Wie es im Betreff schon beschrieben ist versuche ich 2 ADCs mit jewweils 
2 Channel zu betreiben, also ADC1 mit Channel 3,13 und ADC2 mit Channel 
mit 7,9.
Ich habe folgendes Problem....
Nur Channel 3 und Channel 7 liefern mir richtige Werte, die jeweils 
zweiten Channel der beiden ADCs sind falsch.
Ich frage mich desshalb ob etwas in meiner Initialisierung nicht richtig 
eingestellt ist.!?!?
Ich benutze das Board STM32F429 mit KeilUV4.
Danke schon mal fürs lesen und eventuelle Antworten.



int main(void)
{
//Übergabestrukturen
GPIO_InitTypeDef   GPIO_InitStruct; 
ADC_InitTypeDef  ADC_InitStructure;
ADC_CommonInitTypeDef  ADC_CommonInitStructure;
NVIC_InitTypeDef   NVIC_InitStructure;


SystemInit();
SysTick_Config( 3600 );

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); 
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC2, ENABLE);

//Konfigurieren des Ports PC3 (ADC1 Channel13) als analog input 
funktioniert
  GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3;
  GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOC, &GPIO_InitStruct);

//Konfigurieren des Ports PA3 (ADC1 Channel3) als analog input
  GPIO_InitStruct.GPIO_Pin = GPIO_Pin_3;
  GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOA, &GPIO_InitStruct);

//Konfigurieren des Ports PA7 (ADC2 Channel7) als analog input 
funktioniert
  GPIO_InitStruct.GPIO_Pin = GPIO_Pin_7;
  GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOA, &GPIO_InitStruct);

//Konfigurieren des Ports PB1 (ADC2 Channel9) als analog input
  GPIO_InitStruct.GPIO_Pin = GPIO_Pin_1;
  GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AN;
  GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL ;
  GPIO_Init(GPIOB, &GPIO_InitStruct);



//Allgemeine Initialisierung der ADCs
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent; 
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2; 
ADC Takt wird auf die hälfte geteilt = *  1/2
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
ADC_CommonInitStructure.ADC_TwoSamplingDelay = 
ADC_TwoSamplingDelay_5Cycles;
ADC_CommonInit(&ADC_CommonInitStructure);

//Initialisierung des ADC1
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;

ADC_InitStructure.ADC_ExternalTrigConvEdge = 
ADC_ExternalTrigConvEdge_None;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T1_CC1;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfConversion = 2;

ADC_Init(ADC1, &ADC_InitStructure);
ADC_Init(ADC2, &ADC_InitStructure);

//ADC Konfiguration des Kanaele (regular group)
ADC_RegularChannelConfig(ADC2, ADC_Channel_7, 2, 
ADC_SampleTime_3Cycles);
ADC_RegularChannelConfig(ADC2, ADC_Channel_9, 1, 
ADC_SampleTime_3Cycles);
ADC_RegularChannelConfig(ADC1, ADC_Channel_13, 2, 
ADC_SampleTime_3Cycles);
ADC_RegularChannelConfig(ADC1, ADC_Channel_3, 1, 
ADC_SampleTime_3Cycles);

ADC_DMACmd(ADC1, ENABLE);
ADC_DMACmd(ADC2, ENABLE);

ADC_DiscModeCmd(ADC1,ENABLE);
ADC_DiscModeCmd(ADC2,ENABLE);

ADC_EOCOnEachRegularChannelCmd(ADC1, ENABLE);
ADC_EOCOnEachRegularChannelCmd(ADC2, ENABLE);

ADC_ITConfig(ADC1, ADC_IT_EOC, ENABLE);
ADC_ITConfig(ADC2, ADC_IT_EOC, ENABLE);

NVIC_InitStructure.NVIC_IRQChannel = ADC_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);

//Enable ADC
ADC_Cmd(ADC1, ENABLE);
ADC_Cmd(ADC2, ENABLE);

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren