cancel
Showing results for 
Search instead for 
Did you mean: 

ADC reset calibration fails. Ideas why?

ashley23
Associate II
Posted on November 22, 2010 at 23:42

ADC reset calibration fails. Ideas why?

4 REPLIES 4
John F.
Senior
Posted on May 17, 2011 at 14:15

ST advise, ''Before starting a calibration the ADC must have been in power-off state (ADON bit = ‘0’) for at least two ADC clock cycles.''

But ... your code looks very like mine (which works).

void ADC_Configuration(void)

{

  ADC_InitTypeDef  ADC_InitStructure;

  //ADC_ContinuousConvMode  conversion in Continuous or Single mode

  //ADC_DataAlign           ADC data alignment is left or right.

  //ADC_ExternalTrigConv    external trigger for conversion of regular channels

  //ADC_Mode                ADC to operate in independent or dual mode

  //ADC_NbrOfChannel        channels converted using sequencer for regular channel group. range 1..16

  //ADC_ScanConvMode        scan (multichannels) or single (one channel) mode

  //Deinitialize the ADCx peripheral registers to their default reset values.

  ADC_DeInit(ADC1);

  //ADC1 Configuration

  ADC_InitStructure.ADC_ContinuousConvMode = DISABLE;

  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;

  ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;

  ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;

  ADC_InitStructure.ADC_NbrOfChannel = 1;

  ADC_InitStructure.ADC_ScanConvMode = DISABLE;

  ADC_Init(ADC1, &ADC_InitStructure);

  //Enable ADC1 powers ADC for first time (CR2_ADON was 0)

  ADC_Cmd(ADC1, ENABLE);

  ADC_ResetCalibration(ADC1);

  while(ADC_GetResetCalibrationStatus(ADC1));

  ADC_StartCalibration(ADC1);

  while(ADC_GetCalibrationStatus(ADC1));

}

I wonder if you have a high level of optimisation which is messing up the status check.

Do you have a valid VRef? I don't know if this is required.

ashley23
Associate II
Posted on May 17, 2011 at 14:15

VRef is all good...  If I comment out the reset cal line it is all good.  The CAL commmand works perfectly every time.  Just the RSTCAL command that doesn't.  Optimisation is turned off.   

John F.
Senior
Posted on May 17, 2011 at 14:15

The function uses SET and RESET. Have you possibly re-defined them somehow? I think this has previously been a problem for some people.

John F.
Senior
Posted on May 17, 2011 at 14:15

Did you solve this problem?