AnsweredAssumed Answered

STM32F303 ADC Calibration procedure

Question asked by spazzini.fabio on Dec 4, 2013
Latest reply on Dec 5, 2013 by spazzini.fabio
Goodmorning,
I have a problem with the ADC calibration procedure: when I use stm32discovery kit, the software I made works. If I load the SAME SOFTWARE in the processor of application circuit, the calibration procedure never end. In both case the processor is STM32F303.

  NVIC_InitStructure.NVIC_IRQChannel = ADC1_2_IRQn;   // canale di interrupt
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
 
  /*NVIC_InitStructure.NVIC_IRQChannel = ADC3_IRQn;   // canale di interrupt
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);*/
  
  //external_interrupt_config();
  // SETTAGGIO CANALI
  ADC_DeInit(ADC1);
  ADC_DeInit(ADC2);
  ADC_DeInit(ADC3);
  ADC_DeInit(ADC4);
    
  
  /* Calibration procedure */  
  ADC_VoltageRegulatorCmd(ADC1, ENABLE);
  ADC_VoltageRegulatorCmd(ADC2, ENABLE);
  ADC_VoltageRegulatorCmd(ADC3, ENABLE);
  ADC_VoltageRegulatorCmd(ADC4, ENABLE);
  
  /* Insert delay equal to 10 µs */
  Delay(10000);
  
  ADC_SelectCalibrationMode(ADC1, ADC_CalibrationMode_Single);
  ADC_StartCalibration(ADC1);


  ADC_SelectCalibrationMode(ADC2, ADC_CalibrationMode_Single);
  ADC_StartCalibration(ADC2);
  
  ADC_SelectCalibrationMode(ADC3, ADC_CalibrationMode_Single);
  ADC_StartCalibration(ADC3);
 
  ADC_SelectCalibrationMode(ADC4, ADC_CalibrationMode_Single);
  ADC_StartCalibration(ADC4);
  
  while(ADC_GetCalibrationStatus(ADC1) != RESET );
  calibration_value = ADC_GetCalibrationValue(ADC1);
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);
 
  /*NVIC_InitStructure.NVIC_IRQChannel = ADC3_IRQn;   // canale di interrupt
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);*/
  
  //external_interrupt_config();
  // SETTAGGIO CANALI
  ADC_DeInit(ADC1);
  ADC_DeInit(ADC2);
  ADC_DeInit(ADC3);
  ADC_DeInit(ADC4);
    
  
  /* Calibration procedure */  
  ADC_VoltageRegulatorCmd(ADC1, ENABLE);
  ADC_VoltageRegulatorCmd(ADC2, ENABLE);
  ADC_VoltageRegulatorCmd(ADC3, ENABLE);
  ADC_VoltageRegulatorCmd(ADC4, ENABLE);
  
  /* Insert delay equal to 10 µs */
  Delay(10000);
  
  ADC_SelectCalibrationMode(ADC1, ADC_CalibrationMode_Single);
  ADC_StartCalibration(ADC1);

  ADC_SelectCalibrationMode(ADC2, ADC_CalibrationMode_Single);
  ADC_StartCalibration(ADC2);
  
  ADC_SelectCalibrationMode(ADC3, ADC_CalibrationMode_Single);
  ADC_StartCalibration(ADC3);
 
  ADC_SelectCalibrationMode(ADC4, ADC_CalibrationMode_Single);
  ADC_StartCalibration(ADC4);
  
  while(ADC_GetCalibrationStatus(ADC1) != RESET );
  calibration_value = ADC_GetCalibrationValue(ADC1);



The software never ends the while cycle.
Vref+ and Vref- are quite the same in both circuits.
Why the calibration procedure never ends? I don't think is a software problem. Is right to suppose is a hardware problem? Have you got any advice for explain the different behaviours?

Outcomes