AnsweredAssumed Answered

STM32F303K8 ADC Calibration phase problem

Question asked by giacomo.cimarelli on Jan 2, 2017
Latest reply on Jan 10, 2017 by Khouloud G

This is my CODE:

 

void ADC_t_init(void)
{
    ADC_InitTypeDef          ADC_InitStrc;
    ADC_CommonInitTypeDef     ADC_CmmInitStrc;

 

    /* Configure the ADC clock */
    RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div256);

 

    /* Enable ADC1 clock */
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ADC12, ENABLE);

 

    /* Calibration procedure */
    ADC_StructInit(&ADC_InitStrc);
    ADC_Init(ADC1, &ADC_InitStrc);

 

    ADC_Cmd(ADC1, DISABLE);
    ADC_VoltageRegulatorCmd(ADC1, ENABLE);
    /* Insert delay equal to 10 µs */
    Delay(10);

 

    ADC_SelectCalibrationMode(ADC1, ADC_CalibrationMode_Single);
    ADC_StartCalibration(ADC1);

 

    while(ADC_GetCalibrationStatus(ADC1));
    calibration_value = ADC_GetCalibrationValue(ADC1);


    ADC_CmmInitStrc.ADC_Mode                 = ADC_Mode_Independent;
    ADC_CmmInitStrc.ADC_Clock                 = ADC_Clock_AsynClkMode;
    ADC_CmmInitStrc.ADC_DMAAccessMode         = ADC_DMAAccessMode_Disabled;
    ADC_CmmInitStrc.ADC_DMAMode             = ADC_DMAMode_OneShot;
    ADC_CmmInitStrc.ADC_TwoSamplingDelay     = 0;

 

    ADC_CommonInit(ADC1, &ADC_CmmInitStrc);
    ADC_InitStrc.ADC_ContinuousConvMode     = ADC_ContinuousConvMode_Enable;
    ADC_InitStrc.ADC_Resolution             = ADC_Resolution_12b;
    ADC_InitStrc.ADC_ExternalTrigConvEvent     = ADC_ExternalTrigConvEvent_0;
    ADC_InitStrc.ADC_ExternalTrigEventEdge     = ADC_ExternalTrigEventEdge_None;
    ADC_InitStrc.ADC_DataAlign                 = ADC_DataAlign_Right;
    ADC_InitStrc.ADC_OverrunMode             = ADC_OverrunMode_Disable;
    ADC_InitStrc.ADC_AutoInjMode             = ADC_AutoInjec_Disable;
    ADC_InitStrc.ADC_NbrOfRegChannel         = 1;
    ADC_Init(ADC1, &ADC_InitStrc);

 

    /* ADC1 Temperature sensor configuration */
    ADC_RegularChannelConfig(ADC1, ADC_Channel_TempSensor, 1, ADC_SampleTime_601Cycles5);
    /* Enable ADC1 */
    ADC_Cmd(ADC1, ENABLE);

 

    /* Enable temperature sensor */
    ADC_TempSensorCmd(ADC1,ENABLE);

 

    /* wait for ADRDY */
    while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_RDY));

 

    /* Start ADC1 Software Conversion */
    ADC_StartConversion(ADC1);
}

 

and the program not exit from:

while(ADC_GetCalibrationStatus(ADC1));

 

anyone know where is the problem?

thenks for help.

Outcomes