cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f3 discovery ADC conversion status always at reset

d4ng3r09
Associate II
Posted on September 28, 2014 at 13:18

Hi, i configured adc 1 channel 1 for stm32f3 discovery as below.

My  problem is that when i start conversion the ADC_GetStartConversionStatus never turns on the set status.

Thank you for your interest.

&sharpinclude ''stm32f30x.h''

&sharpinclude ''stm32f30x_adc.h''

&sharpinclude ''stm32f30x_gpio.h''

&sharpinclude ''stm32f30x_rcc.h''

__IO uint32_t TimingDelay = 10;

int main(void) {

ADC_InitTypeDef ADC_InitStruct;

GPIO_InitTypeDef GPIO_InitStruct;

ADC_CommonInitTypeDef ADC_CommonInitStructure;

int test = ADC_CR_ADCAL;

TimingDelay = 10;

int ConvValue = 0;

int calibration_value;

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ADC12, ENABLE);

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);

RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div1);

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;

GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AN;

GPIO_InitStruct.GPIO_Speed = GPIO_Speed_2MHz;

GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;

GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;

GPIO_Init(GPIOA, &GPIO_InitStruct);

GPIO_PinLockConfig(GPIOA, GPIO_Pin_0);

ADC_InitStruct.ADC_ContinuousConvMode = ADC_ContinuousConvMode_Enable;

ADC_InitStruct.ADC_Resolution = ADC_Resolution_12b;

ADC_InitStruct.ADC_ExternalTrigConvEvent = ADC_ExternalTrigConvEvent_0;

ADC_InitStruct.ADC_ExternalTrigEventEdge = ADC_ExternalTrigEventEdge_None;

ADC_InitStruct.ADC_DataAlign = ADC_DataAlign_Right;

ADC_InitStruct.ADC_OverrunMode = DISABLE;

ADC_InitStruct.ADC_AutoInjMode = DISABLE;

ADC_InitStruct.ADC_NbrOfRegChannel = 1;

ADC_Init(ADC1,&ADC_InitStruct);

ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;

ADC_CommonInitStructure.ADC_Clock = ADC_Clock_AsynClkMode;

ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;

ADC_CommonInitStructure.ADC_DMAMode = ADC_DMAMode_OneShot;

ADC_CommonInitStructure.ADC_TwoSamplingDelay = 9;

ADC_CommonInit(ADC1, &ADC_CommonInitStructure);

ADC_RegularChannelConfig(ADC1, ADC_Channel_1, 1, ADC_SampleTime_1Cycles5);

ADC_VoltageRegulatorCmd(ADC1, ENABLE);

do {

TimingDelay--;

} while (TimingDelay > 0);

ADC_SelectCalibrationMode(ADC1, ADC_CalibrationMode_Single);

ADC_StartCalibration(ADC1);

while (ADC_GetCalibrationStatus(ADC1) != RESET)

;

calibration_value = ADC_GetCalibrationValue(ADC1);

ADC_RegularChannelSequencerLengthConfig(ADC1, 1);

ADC_Cmd(ADC1, ENABLE);

ADC_StartConversion(ADC1);

//while (ADC_GetStartConversionStatus(ADC1) == RESET)  this line is commented because i always get RESET as an output

//;

while (1) {

while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) != RESET) {

ConvValue = ADC_GetConversionValue(ADC1);

// ADC_ClearFlag(ADC1, ADC_FLAG_EOC);

//TimingDelay++;

}

}

return (0);

}

#continuous-mode #adc #stm32f3
0 REPLIES 0