cancel
Showing results for 
Search instead for 
Did you mean: 

ADC_DR Register always empty

b_
Associate II
Posted on July 28, 2014 at 11:40

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_*** 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? #stm32 #adc_dr #adc
2 REPLIES 2
Posted on July 28, 2014 at 13:10

PG8 isn't connected to any ADC, and clearly isn't ADC_Channel_1

Please review the Data Sheet/Manual for your part to understand available connectivity.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
b_
Associate II
Posted on July 28, 2014 at 14:08

Ha! Stupid me!

I mixed my GPIOs up.

Works well now. Thx a lot.