2025-01-20 03:55 AM
i have an example code which reads the adc value in continuous conversion mode with dma. I have done all the initialization part but its doesn't work for contionus conversion which shows some random values for adc.But it do work for single conversion. The only changes made is i have disabled the continuous for single conversion.
AdcHandle.Instance = ADCx;
AdcHandle.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV2;
AdcHandle.Init.Resolution = ADC_RESOLUTION_12B;
AdcHandle.Init.ScanConvMode = DISABLE;
AdcHandle.Init.ContinuousConvMode = DISABLE;
AdcHandle.Init.DiscontinuousConvMode = DISABLE;
AdcHandle.Init.NbrOfDiscConversion = 0;
AdcHandle.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
AdcHandle.Init.ExternalTrigConv = ADC_EXTERNALTRIGCONV_T1_CC1;
AdcHandle.Init.DataAlign = ADC_DATAALIGN_RIGHT;
AdcHandle.Init.NbrOfConversion = 1;
AdcHandle.Init.DMAContinuousRequests = ENABLE;
AdcHandle.Init.EOCSelection = DISABLE;
if(HAL_ADC_Init(&AdcHandle) != HAL_OK)
{
/* Initialization Error */
Error_Handler();
}
why it is not working for continuous conversion mode with DMA ,if i have change the code to AdcHandle.Init.ContinuousConvMode = ENABLE;
2025-01-20 04:20 AM
Hello @AiswaryaLakshmi ,
First let me thank you for posting and welcome to the ST Community.
For more investigation, I suggest that you provide the STM32CubeMX version that you are using.
Thanks
Mahmoud
2025-01-20 04:31 AM
This setup does make limited sense.
Continuous conversion immediately starts a new conversion after the last one finished, overwriting the previous result. If you pick it from the ADC result register directly or a memory location DMA transfers it to does not matter in this case.
Continuous conversion is useful when you read a channel at random intervals, and want a recent value.
DMA only saves you time and effort if you convert multiple channels. You usually have a sequence of channels / conversions, and want a DMA-TC interrupt when one sequence has finished.