STM32F303K8 Nucleo Restart ADC For Continuous Scans (Using Interrupt?) STM22CubeMX

I have a project generated from CubeMX for my STM32Nucleo F303K8. My IDE is SystemWorkbench.

I am not sure how to properly read these. I am using DMA and the frequency in which I check the value is much slower than the scan time. But even if it wasn't, I wouldn't care if I read the same value twice.

I just want to have a continuous scan, when one finishes the next starts.

But whatever I try to do, it seems that the only way I can get continuous scans is by manually starting the ADC scans over and over in my main loop using:

HAL_ADC_Start(&hadc1);


or the _IT variant.

I have tried enabling continuous conversion and then starting the ADC once outside my main loop. But that just does one scan and stops there.

I thought maybe I could just use the scan complete interrupt to restart the scan when it finishes. This works when I restart only one ADC inside the interrupt. However as soon as I add the second to the callback then the system locks up. Obviously there is an interrupt not being handled somewhere.

 /**
* @brief Callback when an ADC scan completes.
*/
{
{
}
{
}

}


My full code is here: Current commit refid: ef11437

If anyone has any insight for me that would be greatly appreciated.

• Use this with DMA HAL_ADC_Start_DMA(&hadc1, ADC_buffers.ADC1_Buffer, ADC_BUFFER_LENGTH);. – Bence Kaulics Sep 8 '17 at 13:47
• You have to handle the appropriate DMA channel and ADC IRQs. – Bence Kaulics Sep 8 '17 at 13:53
• @Bence Kaulics even better DMA interrupts instead of ADC ones as it assures that transfers are completed, not only the conversions – 0___________ Sep 8 '17 at 23:34
• This is NOT a forum where you mark a thread solved. This is a question and answer site where you ask a question and people post answers. Since you found the solution yourself, you can post an answer and accept it so that the question is properly completed. – JRE Sep 9 '17 at 13:39
• Don't edit the solution into the question, remove that and post an answer, and then after the waiting period for self-answers, accept it. This is the only way to mark a question as resolved in the stack exchange system. – Chris Stratton Sep 9 '17 at 15:09

Also, I realize that I do not need ADC interrupts enabled to restart the conversion. Since the DMA automatically attaches HAL_ADC_ConvCpltCallback to the conversion complete DMA interrupt.