Skip to main content
Associate II
May 15, 2024
Solved

STM32F373 HAL functions for SDADC

  • May 15, 2024
  • 10 replies
  • 7495 views

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

}

This topic has been closed for replies.
Best answer by mƎALLEm

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

10 replies

mƎALLEm
ST Technical Moderator
May 15, 2024

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 "Best answer" on the reply which solved your issue or answered your question.
VeroAuthor
Associate II
May 15, 2024

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

 

mƎALLEm
ST Technical Moderator
May 15, 2024

Check R52 0 ohm resistor,  already soldered?

SofLit_0-1715782423445.png

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
VeroAuthor
Associate II
May 16, 2024

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?

VeroAuthor
Associate II
May 17, 2024

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

VeroAuthor
Associate II
May 17, 2024

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

 

VeroAuthor
Associate II
May 17, 2024

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...

 

mƎALLEm
mƎALLEmBest answer
ST Technical Moderator
May 17, 2024

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 "Best answer" on the reply which solved your issue or answered your question.
VeroAuthor
Associate II
May 17, 2024

thank you!

if I need it will come back here to you