How to correctly and repetitively stop and restart ADC with DMA in STM32L476RG?
I need to measure signal a number of samples before the trigger and a number of samples after the trigger.
I set: DMA in circular mode, ADC in continuous conversion mode, DMA continuous requests, overrun data overwritten, 1 channel, sampling time 2.5 cycles
I start ADC with:
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc_buffer, ADC_BUFFER_LEN
and it waits for the trigger.
When I get the trigger I let to fill DMA buffer till next HAL_ADC_ConvHalfCpltCallback
or HAL_ADC_ConvCpltCallback
and in the callback I use HAL_ADC_Stop_DMA(hadc1)
.
When it is stopped I make processing the data and then I try to restart ADC with HAL_ADC_Start_DMA(&hadc1, (uint32_t*)adc_buffer, ADC_BUFFER_LEN)
.
Unfortunately it doesn't start anymore. Do you have any suggestions why it doesn't restart or how to make better this scenario to get samples before and after the random triggers?