On the other hand, in the datasheet (DS41441B) for the PIC12F1840 the DAC block diagram (Fig. 17-1) does not show DACNSS; however, register DACCON0 contains the DACNSS bit.
So does the DACNSS bit exist in the 1822 or not?
A search in the Microchip forum reveals that the DACNSS bit isn't available on the 12F1822 and that the negative voltage source defaults to VSS.
Okay, so the 1822 is referenced to ground. According to the datasheet, output voltage of the DAC is determined via the following equation:
VOUT = (VSOURCE+ - VSOURCE-)(DACCON1 / 25) + VSOURCE-
This means that if DACCON1 = 0, then VOUT = VSOURCE- = VSS.
But that isn't what I get while measuring the output at the DACOUT pin (enabled by setting the DACOE bit in DACCON0). Using the PICkit2 (with the ICSPDAT disconnected since that pin is also DACOUT) to power the 1822 and setting its VDD = 3.3 and with DACCON1 = 0 and DACPSS configured to use VDD, the Fluke 8842A DMM and Rigol DS1102E oscilloscope both measured DACOUT voltage at 332 to 333mV. It should read zero. 333mV is what we'd expect if DACCON1 is loaded with 0x03. Incidentally using the Fluke 8842A VDD was measured to be 3.42V.
With DACCON1 = 0x1F (decimal 31), VOUT = 3.32V. This is as expected as per the equation above. A summary of DACCON values tested are shown below.
|DACCON1||VOUT measured (volts)||VOUT computed (volts)|
Clearly, computed and measured values are planets apart.
Just to make sure the high impedance DACOUT wasn't being loaded, an op amp configured as a voltage follower (unity gain buffer) was used to buffer the DAC output, but the values obtained were the same as above.
Setting or clearing ANSELA has no effect on DACOUT output either.
I also tested the DAC "low power voltage state" by clearing DACEN, clearing DACLPS, and clearing DACCON1. Output at DACOUT was 313mV. It should be zero.
With DACCON0 cleared--i.e., DAC is completely disabled--and RA0/DACOUT pin configured as digital output and PORTA cleared, voltage reading was 2.5mV. So RA0 works as expected and voltage on this pin can in fact go down to practically zero.
So is there something very wrong with the DAC unit or have i missed some SFR setting?