Saturday, May 28, 2011

Test driving the PIC12F1822's DAC

Trying out the digital to analog converter (DAC) of the PIC12F1822. The most current datasheet (DS41413B) has bugs. The DAC block diagram (Fig.17-1) and description in Section 17 both indicate the existence of a negative voltage source (VSOURCE-) which is selectable via the DACNSS bit. But neither of the two DAC registers--DACCON0 and DACCON1--has the DACNSS bit.

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:


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)
0x00 0.333 0
0x01 0.760 0.106
0x02 1.074 0.213
0x03 1.328 0.320
0x04 1.533 0.427
0x08 2.093 0.855
0x10 2.640 1.710
0x1F 3.320 3.313

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?

1 comment:

  1. Hello,

    I have the same problème since yesterday. Did you find a solution?