cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F373 HAL functions for SDADC

Vero
Associate II

Hello guys,

 I tried to use the HAL_SDAC functions to read two Analog signals (0-3.3V) with DMA but I didn't have good results.

That's why I started reading only one Analog signal in Polling mode (ING 5)....unfortunately even in this case I always read zero (AD_result=0)

I am using the STM32F373 and STM32CubeIDE.

Any good ideas?

My configuration:

Vero_0-1715778269997.pngVero_1-1715778306014.png

 

The code in main.c:

/* Initialize all configured peripherals */

MX_SDADC1_Init();

HAL_SDADC_CalibrationStart(&hsdadc1, SDADC_CALIBRATION_SEQ_1)

HAL_SDADC_PollForCalibEvent(&hsdadc1, 10);

 

HAL_SDADC_SelectRegularTrigger(&hsdadc1, SDADC_SOFTWARE_TRIGGER);

 

HAL_SDADC_AssociateChannelConfig(&hsdadc1, SDADC_CHANNEL_5, SDADC_CONF_INDEX_0) ;

HAL_SDADC_ConfigChannel(&hsdadc1, SDADC_CHANNEL_5, SDADC_CONTINUOUS_CONV_OFF);

 

HAL_SDADC_Start(&hsdadc1);

 

while (1){

HAL_SDADC_PollForConversion(&hsdadc1, 100); // Poll ADC1 Peripheral & TimeOut = 1mSec

AD_result = HAL_SDADC_GetValue(&hsdadc1); // Read ADC Conversion Result

}

10 REPLIES 10
SofLit
ST Employee

Hello,

Check your Vref voltage and I invite you to look at the examples of SDADC provided in STM32CubeF3 located under https://github.com/STMicroelectronics/STM32CubeF3/tree/master/Projects/STM32373C_EVAL/Examples/SDADC

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

I am using the ST demo board STM32373C-EVAL and the PB1 GPIO pin with the potentiometer.

The Vref is good..:grinning_face:

Vero_0-1715782036923.png

 

Check R52 0 ohm resistor,  already soldered?

SofLit_0-1715782423445.png

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Yes, is soldered. 

I used the same ADC_POT_IN with the ADC 12 bit and is working well...so the HW is ok...

Vero
Associate II

news...it seems if I do START and STOP of conversion whenever on the while loop the AD_result  is changing

 

while (1){

 

HAL_SDADC_Start(&hsdadc1);

HAL_SDADC_PollForConversion(&hsdadc1, 100); // Poll ADC1 Peripheral & TimeOut = 1mSec

AD_result = HAL_SDADC_GetValue(&hsdadc1); // Read ADC Conversion Result

HAL_SDADC_Stop(&hsdadc1);

}

 

This even though I put continuous mode ENABLE:

Vero_0-1715854661899.png

Now I'll drop this example in polling and try again to read 2 Analog signals (0-3.3V) with trigger timer and DMA.

In this mode (2 channels)  the only via in to use the injected conversion...correct?

Vero
Associate II

news... 2 analog signals ( injected conversion mode) with trigger software (no timer) and NO DMA is working....

 

 in MAIN:

MX_SDADC1_Init();

if( HAL_SDADC_CalibrationStart(&hsdadc1, SDADC_CALIBRATION_SEQ_1)!= HAL_OK)

HAL_SDADC_PollForCalibEvent(&hsdadc1, 10);

/* Start injected conversion in interrupt mode */

if (HAL_SDADC_InjectedStart_IT(&hsdadc1) != HAL_OK)

...................

 

void HAL_SDADC_InjectedConvCpltCallback(SDADC_HandleTypeDef *hsdadc)

{

/* Get conversion value */

if(ch==1)

{

measurements_SDADC[0] = HAL_SDADC_InjectedGetValue(&hsdadc1, &ch);}

else{

measurements_SDADC[1] = HAL_SDADC_InjectedGetValue(&hsdadc1, &ch);

}

}

 

Now I will try whit DMA and timer trigger

Vero
Associate II

The configuration for the previously example (2 analog signals ( injected conversion mode) with trigger software (no timer) and NO DMA)

 

Vero_0-1715932495912.pngVero_1-1715932510377.png

 

Vero
Associate II

Where I find the code examples of the SDADC Wave recorder ( cap 5.3 of AN4207)?

This example uses TIM3 as a trigger and DMA...maybe is the example for me...

 

Hello,

The example is a part of STM32373C-EVAL demonstration firmware package downloadable from here.

located under: STM32373C-EVAL_FW_V1.0.0\Project\STM32373C-EVAL\src\waverecorder.c

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.