cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot read VREFINT Accurately on STM8L052C6 48 pin package

iron
Associate II
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
3 REPLIES 3
iron
Associate II
Posted on December 14, 2012 at 04:07

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

vivavivy
Associate
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

vivavivy
Associate
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;