Electronic – PIC microcontroller DAC output incorrect

analogdacpic

Using a PIC16F1825 microcontroller I was seeing incorrect values being output on the DACOUT pin. The setup stipulated using the fraction 8/32 * VREF+ where VREF+ was an external 2.5V reference. The output should have been 0.625 but was twice that value.

(have answer myself)

Best Answer

The answer is two fold:

Firstly - pull up resistors are enabled by default on all input ports when WPUEN# in OPTION_REG is cleared. This will affect analog inputs like VREF+ and may affect analog outputs like DACOUT. I'm not certain on the last point as I have not tested that assertion - it seems wrong on the face of it though. This is true for the PIC16F1825 but may not be true for other PIC micros in other ranges.

Secondly - the DACOUT and VREF+ pins are, on this micro, shared with the PGD and PGC pins. If a PICKIT3 is connected, that device has 4k7 pull down resistors on both these pins.

If using VREF+ or DACOUT, make sure pullups are disabled and the PICKIT3 is disconnected.