Skip to main content
Konami
Senior
January 18, 2018
Solved

Issues with STM32L4 ADC (Full Scale Reading)

  • January 18, 2018
  • 7 replies
  • 1688 views
Posted on January 18, 2018 at 17:30

The original post was too long to process during our migration. Please click on the attachment to read the original post.
    This topic has been closed for replies.
    Best answer by Konami
    Posted on January 22, 2018 at 16:50

    The difference was the VREF+ pin. VREF+ and VDDA are not double bonded on the 100LQFP package and since VREF+ was not connected externally in the design it was not being powered. Adding the below code fixed the issue:

      /**Configure the VREFBUF */

      HAL_SYSCFG_VREFBUF_VoltageScalingConfig(SYSCFG_VREFBUF_VOLTAGE_SCALE0);

      HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);

      if (HAL_SYSCFG_EnableVREFBUF() != HAL_OK)

      {

           _Error_Handler(__FILE__, __LINE__);

      }  

    7 replies

    Bogdan Golab
    Lead
    January 18, 2018
    Posted on January 18, 2018 at 17:48

    Can you share the code and tell us what pins you are trying to use? What is the source of DC voltage you want to measure. How did you wired the pins (pot or resistor divider, etc)

    Konami
    KonamiAuthor
    Senior
    January 18, 2018
    Posted on January 18, 2018 at 20:36

    I've updated the question with the code. Some of the pins I've just been manually shorting to VCC (3.3) or GND, but PA0 is connected to a temperature sensor like below which is putting PA0 at 1.3V roughly. If multiple ADC channels are configured how do I know which one I'm converting when I receive the interrupt?

    0690X00000609QlQAI.png
    waclawek.jan
    Super User
    January 18, 2018
    Posted on January 18, 2018 at 20:52

    By counting the interrupts... you programmed the conversion sequence so you know which interrupt number belongs to which conversion.

    JW

    Konami
    KonamiAuthor
    Senior
    January 18, 2018
    Posted on January 18, 2018 at 20:58

    Okay that makes sense, but I'm still only seeing 3 interrupts and they are all measuring 0xFFF

    Konami
    KonamiAuthor
    Senior
    January 18, 2018
    Posted on January 18, 2018 at 22:41

    The 476 has a multimode option which I don't think is available on the 431. That's the only difference I can see between the two.

    Konami
    KonamiAuthorBest answer
    Senior
    January 22, 2018
    Posted on January 22, 2018 at 16:50

    The difference was the VREF+ pin. VREF+ and VDDA are not double bonded on the 100LQFP package and since VREF+ was not connected externally in the design it was not being powered. Adding the below code fixed the issue:

      /**Configure the VREFBUF */

      HAL_SYSCFG_VREFBUF_VoltageScalingConfig(SYSCFG_VREFBUF_VOLTAGE_SCALE0);

      HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);

      if (HAL_SYSCFG_EnableVREFBUF() != HAL_OK)

      {

           _Error_Handler(__FILE__, __LINE__);

      }