cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F303 ADC Calibration procedure

spazzing86
Associate
Posted on December 04, 2013 at 12:22

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?
2 REPLIES 2
Posted on December 04, 2013 at 17:07

Not sure I understand some of the repetition of code here, but if it's hanging up in loops, you might want to pay particular attention to the clock sources, that they are enabled, and that the settings are valid.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
spazzing86
Associate
Posted on December 05, 2013 at 08:50

Thank you for your reply.

When you talk about ''clock sources'', do you think something like this instruction?

/* Configure the ADC clock */

RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div2);

/* Enable ADC1 clock */

RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ADC12, ENABLE);

Yes, there's these instruction. The same code run correctly on the discovery kit but doesn't works on my application circuit. For this reason I suppose it's an hardware problem.

I've attached the schematics. Is it correct?

________________

Attachments :

Sheet1_Re520B.pdf : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0or&d=%2Fa%2F0X0000000be1%2FvDGq.5hqdbcwD0gfBrOjr4LRrh.fT6aW_jhvd.1ss8g&asPdf=false