cancel
Showing results for 
Search instead for 
Did you mean: 

SDADC speed, accuracy and calibration.

es131245
Associate II

Trying to get best of STM32F373CCT6 & its differental moded SDADC1 for a pressisios bridge type sensor.

Datasheet's say that the SDADC speed limit is 50kS per second.

Ive reached only 68uSec (~15k) for this

HAL_GPIO_WritePin(GPIOA,GPIO_PIN_4,GPIO_PIN_SET);
 HAL_SDADC_InjectedStart_IT(&adc);
...
void HAL_SDADC_InjectedConvCpltCallback(SDADC_HandleTypeDef*hadc)
{adcData=HAL_SDADC_InjectedGetValue(&hadc,(uint32_t*)&InjChannel);
 HAL_SDADC_InjectedStop_IT(&adc);

Adding DMA makes it 72uSec. Is there any way to speed up SDADC ?

Other quastions are SDADC GAIN and OFFSET calbration sequences

AN4207 have calibration description shows only single ended mode.

Should diffrential SDADC be calibrated the same way?

Figure 8 shows that pins should be connected to Voltage ref.

Havent found what nominal should it be.

Ok. Hal has 3 "SDADC_CALIBRATION_SEQ"s.

1rst is offset. 2nd is gain. What is the 3rd seq?

Can offet and gain coenficients be reset to set manualy?

Here is some code

pci.PeriphClockSelection=RCC_PERIPHCLK_SDADC;
 pci.SdadcClockSelection=RCC_SDADCSYSCLK_DIV12;
 if(HAL_RCCEx_PeriphCLKConfig(&pci)!=HAL_OK)Error_Handler();
...
 __HAL_RCC_GPIOB_CLK_ENABLE();
 __HAL_RCC_SDADC1_CLK_ENABLE();
...
 HAL_GPIO_WritePin(GPIOB,GPIO_PIN_0|GPIO_PIN_1,GPIO_PIN_RESET);
 pin.Pull=GPIO_NOPULL;
 pin.Speed=GPIO_SPEED_FREQ_HIGH;
 pin.Pin=GPIO_PIN_0|GPIO_PIN_1;
 pin.Mode=GPIO_MODE_ANALOG;
 HAL_GPIO_Init(GPIOB,&pin);
...
 adc.Instance=SDADC1;
 adc.Init.IdleLowPowerMode=SDADC_LOWPOWER_NONE;
 adc.Init.FastConversionMode=SDADC_FAST_CONV_DISABLE;
 adc.Init.SlowClockMode=SDADC_SLOW_CLOCK_DISABLE;
 adc.Init.ReferenceVoltage=SDADC_VREF_EXT;
 if(HAL_SDADC_Init(&adc)!=HAL_OK)Error_Handler();
 cfg.InputMode=SDADC_INPUT_MODE_DIFF;
 cfg.Gain=SDADC_GAIN_4;
 cfg.CommonMode=SDADC_COMMON_MODE_VSSA;
 cfg.Offset=0;//0x7fff;
 if(HAL_SDADC_PrepareChannelConfig(&adc,SDADC_CONF_INDEX_0,&cfg)!=HAL_OK)Error_Handler();
  HAL_SDADC_AssociateChannelConfig(&adc,SDADC_CHANNEL_6,SDADC_CONF_INDEX_0);
HAL_SDADC_InjectedConfigChannel(&adc,SDADC_CHANNEL_6,SDADC_CONTINUOUS_CONV_OFF);
  HAL_SDADC_SelectInjectedTrigger(&adc,SDADC_SOFTWARE_TRIGGER);
//  HAL_SDADC_CalibrationStart(&adc,SDADC_CALIBRATION_SEQ_1);
//  HAL_SDADC_PollForCalibEvent(&adc,HAL_MAX_DELAY);
...
 HAL_NVIC_SetPriority(SDADC1_IRQn,8,8);
 HAL_NVIC_EnableIRQ(SDADC1_IRQn);
...
void SDADC1_IRQHandler(void){HAL_SDADC_IRQHandler(&adc);}
void HAL_SDADC_InjectedConvCpltCallback(SDADC_HandleTypeDef*hadc)
{data=HAL_SDADC_InjectedGetValue(&adc,(uint32_t*)&InjChannel);
 HAL_GPIO_WritePin(GPIOA,GPIO_PIN_4,GPIO_PIN_RESET);
//HAL_SDADC_InjectedStop_IT(&adc);
..
void TIM3_IRQHandler(void)
{__HAL_TIM_CLEAR_FLAG(&timN,TIM_FLAG_UPDATE);
 HAL_GPIO_WritePin(GPIOA,GPIO_PIN_4,GPIO_PIN_SET);
 HAL_SDADC_InjectedStart_IT(&adc);}

1 REPLY 1
es131245
Associate II

Question 1 solved. RM0313 "The conversion speed is up to 16.6 ksps for each SDADC when converting multiple channels and up to 50"