cancel
Showing results for 
Search instead for 
Did you mean: 

STM32f373VC SDADC after offset calibration, the result not accurate?

CLi P.1
Associate

0693W000004KEhVQAW.jpgHi everyone,

I have some questions below:

1.When finished the SDADC calibration, the offset value will auto add to the result value? or I need to take the offset value from the register "SDADC_CONF0R", and sum with them by myself?

(I have already use the debug mode to check the register "SDADC_CONF0R" , the OFFSET value will update after calibration function, so I think the calibration function is working normally. )

2. No use the calibration function on SDADC, the error percent about 3%, and I use the calibration function, the error percent also about 3% (According to question 1, I think the offset not auto sum with result value), and I try sum the offset value with result value (Accroding to the AN4207 page 11, there talk about offset calibration), but got the error percent about 22% ... , so I think I have some part mistake...

3.The offset value be use minus or add? because the register "SDADC_CONF0R" OFFSET only is positive value, this also confuse me.

Below is my setting:

Differential mode

SDVerf+ : 3 V

SDVref- : GND

Diff+ : 0.75 V

Diff- : GND

I got the AD value (without calibration) 16802, through the formula can get the 0.7691 V.

Please give me some suggest, thank you!!!

void Return_SDADC_Value(void)
{
        // Initail SDADC
        MX_SDADC1_Init();
 
	// Internal offset calibration
	HAL_SDADC_CalibrationStart(&hsdadc1, SDADC_CALIBRATION_SEQ_1);
 
	HAL_SDADC_PollForCalibEvent(&hsdadc1, HAL_MAX_DELAY);
	HAL_SDADC_PollForCalibEvent(&hsdadc1, HAL_MAX_DELAY);
 
	HAL_Delay(10);
 
        HAL_SDADC_Start(&hsdadc1);
		
        if (HAL_SDADC_PollForConversion(&hsdadc1, 100) != HAL_OK) 
        {
		Error_Handler();
	}
        else 
        {
		/* ADC conversion completed */
		PE8_Voltage = HAL_SDADC_GetValue(&hsdadc1);
 
		sprintf((char*) aTxBuffer, "%f", PE8_Voltage);
 
		CDC_Transmit_FS(aTxBuffer, (COUNTOF(aTxBuffer)));
		HAL_Delay(1000);
	}
}
void MX_SDADC1_Init(void)
{
 
  SDADC_ConfParamTypeDef ConfParamStruct = {0};
 
  /** Configure the SDADC low power mode, fast conversion mode,
  slow clock mode and SDADC1 reference voltage
  */
  hsdadc1.Instance = SDADC1;
  hsdadc1.Init.IdleLowPowerMode = SDADC_LOWPOWER_NONE;
  hsdadc1.Init.FastConversionMode = SDADC_FAST_CONV_DISABLE;
  hsdadc1.Init.SlowClockMode = SDADC_SLOW_CLOCK_DISABLE;
  hsdadc1.Init.ReferenceVoltage = SDADC_VREF_EXT;
  if (HAL_SDADC_Init(&hsdadc1) != HAL_OK)
  {
    Error_Handler();
  }
  /** Configure The Regular Mode
  */
  if (HAL_SDADC_SelectRegularTrigger(&hsdadc1, SDADC_SOFTWARE_TRIGGER) != HAL_OK)
  {
    Error_Handler();
  }
  /** Set parameters for SDADC configuration 0 Register
  */
  ConfParamStruct.InputMode = SDADC_INPUT_MODE_DIFF;
  ConfParamStruct.Gain = SDADC_GAIN_1;
  ConfParamStruct.CommonMode = SDADC_COMMON_MODE_VSSA;
  ConfParamStruct.Offset = 0;
  if (HAL_SDADC_PrepareChannelConfig(&hsdadc1, SDADC_CONF_INDEX_0, &ConfParamStruct) != HAL_OK)
  {
    Error_Handler();
  }
  /** Configure the Regular Channel
  */
  if (HAL_SDADC_AssociateChannelConfig(&hsdadc1, SDADC_CHANNEL_6, SDADC_CONF_INDEX_0) != HAL_OK)
  {
    Error_Handler();
  }
  if (HAL_SDADC_ConfigChannel(&hsdadc1, SDADC_CHANNEL_6, SDADC_CONTINUOUS_CONV_ON) != HAL_OK)
  {
    Error_Handler();
  }
 
}

0 REPLIES 0