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

I am using a total of 8 Analog inputs split between two ADC's

ADC1: 1, 2, 4, 12.

ADC2: 1, 2, 3, 4.

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:


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.
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
    if (hadc->Instance == ADC1)
    if (hadc->Instance == ADC2)


My full code is here: Current commit refid: ef11437


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

  • \$\begingroup\$ Use this with DMA HAL_ADC_Start_DMA(&hadc1, ADC_buffers.ADC1_Buffer, ADC_BUFFER_LENGTH);. \$\endgroup\$ Sep 8, 2017 at 13:47
  • 1
    \$\begingroup\$ You have to handle the appropriate DMA channel and ADC IRQs. \$\endgroup\$ Sep 8, 2017 at 13:53
  • \$\begingroup\$ @Bence Kaulics even better DMA interrupts instead of ADC ones as it assures that transfers are completed, not only the conversions \$\endgroup\$ Sep 8, 2017 at 23:34
  • 3
    \$\begingroup\$ 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. \$\endgroup\$
    – JRE
    Sep 9, 2017 at 13:39
  • \$\begingroup\$ 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. \$\endgroup\$ Sep 9, 2017 at 15:09

1 Answer 1


I have managed to find a solution. Although as PeterJ_01 mentions, this may just be a workaround to a much larger problem.

The cause of my problem appears to be that I had the cycle time set to 61.5 cycles per channel. Which seems to be too fast when doing 8 conversions. My suspicion was that I was saturating the µC. Which is why restarting only one ADC in the callback would work. but not both. But I guess it is something deeper than that.

I have upped the cycle time to 601.5 cycles and it all works!

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.