Skip to main content
AWolf.8
Associate II
August 29, 2019
Solved

Simple ADC example

  • August 29, 2019
  • 5 replies
  • 1636 views

I'm having trouble getting the ADC on a STM32L476VGT6 discovery board to work. If I run by configuration code then click the ADSTART bit in the debugger, everything works fine. If I set the ADSTART bit in code in real time, the conversion never finishes.

Anyone have a simple, single-channel, single-conversion ADC example?

This topic has been closed for replies.

5 replies

Mike_ST
Mike_STBest answer
ST Technical Moderator
August 29, 2019
In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
AWolf.8
AWolf.8Author
Associate II
August 29, 2019

Thank you for your response.

I noticed that there are no ADC examples for the STM32L476VGT6 discovery board. There are examples for another STM32L476 board, but as written they use the 80MHz PLL clock which is not present by default on the STM32L476VGT6 discovery board. I will study these other examples, but is there any reason why the ADC would work differently if the system clock is the 4MHz MSI default clock?

AWolf.8
AWolf.8Author
Associate II
August 29, 2019

Well - some progress. I noticed one bug in my code from reading the examples and fixed it. (My code is in assembly). Now if I single step, everything works, but at speed the conversion does not happen. I'm guessing a clocking issue.

AWolf.8
AWolf.8Author
Associate II
August 29, 2019

Problem solved. A standard simple bug. I was checking the ADC_ISR_ADRDY bit backwards so I was running conversions before the ADC was booted. That's why it worked single-step.

waclawek.jan
Super User
August 30, 2019

Thanks for coming back with the solution. Please select your post as Best so that the thread gets marked resolved.

JW