2024-05-15 06:15 AM
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:
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
}
2024-05-15 06:47 AM - edited 2024-05-15 06:47 AM
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
2024-05-15 07:07 AM
I am using the ST demo board STM32373C-EVAL and the PB1 GPIO pin with the potentiometer.
The Vref is good..😀
2024-05-15 07:14 AM
Check R52 0 ohm resistor, already soldered?
2024-05-16 01:28 AM
Yes, is soldered.
I used the same ADC_POT_IN with the ADC 12 bit and is working well...so the HW is ok...
2024-05-16 03:20 AM
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:
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?
2024-05-17 12:53 AM
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
2024-05-17 12:55 AM
The configuration for the previously example (2 analog signals ( injected conversion mode) with trigger software (no timer) and NO DMA)
2024-05-17 01:10 AM
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...
2024-05-17 01:24 AM
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