Skip to main content
Explorer
May 12, 2025
Solved

L476RGT6 ADC1 Driver Not Working (Incorrect Reading)

  • May 12, 2025
  • 1 reply
  • 638 views

Hi! I have the following code for an ADC1 driver running in ADC1_IN1 (PC0) in an L476RGT6 and it runs fine. However, I am testing it by reading a potentiometer and the value read is constant. I've already double-checked everything, including channel selection in ADCx_SQR1, but I am still not sure why it is not reading correctly when I change the potentiometer resistance.

You can assume systick_us_delay() works fine.

    This topic has been closed for replies.
    Best answer by gabofv

    It works by setting the OVRMOD bit in ADC1->CFGR! It is a problem related to the ADC_DR register overflowing, so will try to use DMA for buffering. Thank you very much! Your reply actually made me see it from a different perspective.

    1 reply

    Super User
    May 13, 2025

    > the value read is constant

    Does it  change when you move the pot and restart the program?

    Read out and check/post the ADC registers content.

    JW

    gabofvAuthor
    Explorer
    May 14, 2025

    Yes! Just noticed that. I was kind of frustrated last time I tried debugging it so didn't notice before. I attached the screenshots of the results when moving the pot to one end and then to the other (different runs). The value doesn't change for one run, even if I start moving the pot.

    gabofvAuthorAnswer
    Explorer
    May 14, 2025

    It works by setting the OVRMOD bit in ADC1->CFGR! It is a problem related to the ADC_DR register overflowing, so will try to use DMA for buffering. Thank you very much! Your reply actually made me see it from a different perspective.