AnsweredAssumed Answered

ADC_DR Register always empty

Question asked by button.benjamin on Jul 28, 2014
Latest reply on Jul 28, 2014 by button.benjamin
Hi All,

I'm trying to use the ADC1 GPIO G8 from the STM32F207IG.
Unfortunately I don't get it working and maybe someone could help me.
The basic problem is that all ADC_xxx registers getting updated except the ADC_DR register.
In a first try I would like to configure the ADC for a single conversion without DMA.

A few code lines:
//config Charge Indicator Port as analog input
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG,    ENABLE);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1,     ENABLE);
    GPIO_PortClock      (CHARGE_GPIO, true);
    GPIO_PinConfigure   (CHARGE_GPIO, CHARGE_PINNR, GPIO_MODE_ANALOG, GPIO_OUTPUT_PUSH_PULL, GPIO_OUTPUT_SPEED_2MHz, GPIO_NO_PULL_UP_DOWN);

    ADC_DeInit();
ADC_Common.ADC_DMAAccessMode        = ADC_DMAAccessMode_Disabled;
ADC_Common.ADC_Mode                         = ADC_Mode_Independent;
ADC_Common.ADC_Prescaler                = ADC_Prescaler_Div2;
ADC_Common.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_10Cycles;
ADC_CommonInit(&ADC_Common);   
 
ADC_InitStruct.ADC_ContinuousConvMode   = DISABLE;
ADC_InitStruct.ADC_DataAlign                        = ADC_DataAlign_Right;
ADC_InitStruct.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
ADC_InitStruct.ADC_ExternalTrigConv         = ADC_ExternalTrigConvEdge_None;
ADC_InitStruct.ADC_NbrOfConversion          = 1;
ADC_InitStruct.ADC_Resolution                   = ADC_Resolution_10b;
ADC_InitStruct.ADC_ScanConvMode                 = DISABLE;
ADC_Init(ADC_Device, &ADC_InitStruct);
 
 
ADC_Cmd(ADC_Device, ENABLE);
ADC_RegularChannelConfig(ADC_Device, ADC_Channel_1, 1, ADC_SampleTime_3Cycles);
ADC_DiscModeChannelCountConfig(ADC_Device, 1);
ADC_DiscModeCmd(ADC_Device, ENABLE);
 
 
ADC_ITConfig(ADC_Device, ADC_IT_EOC, ENABLE);
ADC_ExternalTrigInjectedConvEdgeConfig(ADC_Device, ADC_ExternalTrigInjecConvEdge_None);
ADC_ExternalTrigInjectedConvConfig(ADC_Device, ADC_ExternalTrigConvEdge_None);
 
    osDelay(1);
RCC_GetClocksFreq(&xy); //PHB2 = 7.5MHz
 
for(;;){
    ADC_ClearFlag(ADC_Device, ADC_FLAG_EOC);
    ADC_ClearFlag(ADC_Device, ADC_FLAG_STRT);
 
    ADC_SoftwareStartConv(ADC_Device); 
    k = 0;
    while(ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET){
        k++;
    }
 
    value = ADC_GetConversionValue(ADC_Device);
}

It would be very kind if someone could help me out.

Thanks
Benjamin


Addendum:
If I do the exact same with ADC_3_IN_6 GPIOF8 the code works fine.
Do I have to enable something special for ADC1?

Outcomes