Skip to main content
Visitor II
December 14, 2012
Question

Cannot read VREFINT Accurately on STM8L052C6 48 pin package

  • December 14, 2012
  • 3 replies
  • 1291 views
Posted on December 14, 2012 at 03:12

I route VREFINT to an output pin and it reads correctly at 1.22V.

If I vary my input voltage, the VREFINT raw count value drifts around between 1100 and 1300 counts using VDD at 3.22V.  The higher the voltage, the higher the count.

I checked VDD going in and it is rock solid.  Same with VREFINT going out the PC6 (?) pin.

I am in single conversion mode using PF0 (ADCIN24) as my input pin.

Any help appreciated.  thanks, Jim 

#adc
    This topic has been closed for replies.

    3 replies

    ironAuthor
    Visitor II
    December 14, 2012
    Posted on December 14, 2012 at 04:07

    I figured it out.  Set ADON bit to 1 before setting SQR registers.

    Visitor II
    March 9, 2015
    Posted on March 09, 2015 at 11:37

    Hi,

    could you please explain me which step you took in order to route the Vref output to a pin?

    I'm using the same STM8L052 you are using, and I tried setting bit CH7E of RI_IOSR1 register in order to route Vref out of PC2, but I see nothing...

    I assume bit VREFOUTEN of COMP_CSR3 is always set because in 052 family there is no comparators, therefore I assume there is no COMP_CSR3 register. Am I right?

    Thanks,

    Vivy

    Visitor II
    March 9, 2015
    Posted on March 09, 2015 at 12:27

    Ok, I found out. Even if COMP_CSR3 register is not defined as 052 family microprocessor port, the register must be set to enable Vrefouten. 

    This line do the trick:

    *((uint8_t *) (uint16_t)0x5442) |= 1;