cancel
Showing results for 
Search instead for 
Did you mean: 

Is it needed to start ADC_DMA again after waking up from Stop mode?

duybienle
Associate II
Posted on July 21, 2016 at 10:36

Hi,

I want to read a single conversion of multiple channels of an ADC repeatedly, after searching I found the solution that is using ADC_DMA. Since in my porject I need to put the uC into Stop mode after a single conversion of ADC and wait until the next conversion (trigger by LPTIM), however I don't know if I need to start the ADC_DMA again after waking up from Stop mode ?

A simple code to demonstrate the situation is as follow:

int

main(

void

)

{

HAL_Init();

MX_GPIO_Init();

MX_ADC_Init();

MX_TIM2_Init();

if

(HAL_ADCEx_Calibration_Start(&hadc, ADC_SINGLE_ENDED) != HAL_OK)

Error_Handler();

}

/* Start ADC conversion with transfer by DMA */

if

(HAL_ADC_Start_DMA(&hadc, (uint32_t *)ADC_DMA_val, nbrADCchannel) != HAL_OK)

Error_Handler();

}

while

(1)

{

// Is it needed to start DMA again ???????????

// HAL_ADC_Start_DMA(&hadc, (uint32_t *)ADC_DMA_val, nbrADCchannel)

HAL_ADC_Start(&hadc);

HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);

}

}

void

HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc)

{

/* Read captured ADC values */

}

Thanks,

Bien

2 REPLIES 2
Walid FTITI_O
Senior II
Posted on July 21, 2016 at 14:16

Hi  le.bien,

In stop mode, all peripheral clocks are gated. To make your application operate correctly, on entering stop mode , disable ADC then DMA. On return enable DMA then ADC. Note, that if your system clock is different from HSI setting , you out to reconfigure it after exiting the stop mode.

-Hannibal-
duybienle
Associate II
Posted on July 21, 2016 at 16:03

Hi Hannibal

Thanks, your info helps me alot. Just to make sure I understand correctly: - On entering Stop mode:

 HAL_ADC_Stop --> HAL_ADC_Stop_DMA

- On returning from Stop mode:

 HAL_ADC_Start_DMA --> HAL_ADC_Start

And I also have to do the same thing for e.g Timers and other modules right ? Thanks again Bien