ADC with DMA restart
Hello,
I'm using ADC together with DMA.
At first start of ADC and DMA all worked like expected.
At 2nd and following starts, the first value received from DMA is always zero / invalid.
Now I have found out that it works if between two DMA transfers I use
LL_ADC_Disable(ADC2);
and afterwards
LL_ADC_Enable(ADC2);
//code snippet:
LL_DMA_SetDataLength(DMA2, LL_DMA_CHANNEL_1, 100U);
LL_DMA_EnableChannel(DMA2, LL_DMA_CHANNEL_1);
LL_ADC_REG_StartConversion(ADC2);
while (LL_DMA_GetDataLength(DMA2, LL_DMA_CHANNEL_1) > 0U)
{
}
LL_ADC_REG_StopConversion(ADC2);
LL_DMA_DisableChannel(DMA2, LL_DMA_CHANNEL_1);
LL_ADC_Disable(ADC2);
while(LL_ADC_IsDisableOngoing(ADC2))
{
}
LL_ADC_Enable(ADC2);
Now my questions:
Is disable/enable of the ADC absolutely necessary?
Or is there a less brute way to reuse the ADC together with DMA?
Thanks in advance.
Best regards
Johann
