hi,
The Vref for the adc in the 16F627 is an INPUT pin, the Vref is generated externally and connected into the PIC's Vref pin.
EDIT:
I have overlooked VRCON
Thanks Eric, I'm new to electronics and still need to learn everything.
I saw in the datasheet that the PIC has a 16-tap resistor ladder for use with the Vref output, thus the PIC must be able to generate it's own Vref voltage for use with it's own comparators.
The problem is that when I connect my multimeter to pin RA2 (vref output pin), I measure less than 1 volt, when I programmed the Vref module to output 1.25V.
Do you maybe have a simple circuit and source code to show how to use the Vref module?
Alternatively I could also use PWM to generate a voltage between 0V-5V. How should I connect the PWM output to the load and would the source code be that of normal PWM?
hi Jean.
Looking a the VRCON register,for 1.25Vref you need to load it with.
11100110 binary, = 0xE6
Thats the high nibble 'Eh', switches ON and enables the Vref output and sets the range to low.
The 0110, 6h is decimal 6, so Vref = (6/24) * 5Vdd = +1.25V
You will not be able to source 10mA from the Vref output as the resistors in the ladder are 2k each. The maximum current you can draw would be in the order of a few uA. If you tell us what you need it for there may be an alternative solution.
I've come up with an alternative solution to my problem, so I'm not going to use the Vref anymore. I am now using a potentiometer connected to my microcontroller. I need three states (0V, 2.5V and 5V). What I did was to connect the two ends of the potentiometer to my microcontroller. When I require 0V, I sink both outputs. When I require 2.5V (or anything between 0 and 5V), I source one output and sink the other and finally when I require 5V, I just source both outputs.