AnsweredAssumed Answered

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

Question asked by le.bien on Jul 21, 2016
Latest reply on Jul 21, 2016 by le.bien

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

Outcomes