Hacking the PIC32 Comparator Reference to obtain a DAC
The PIC32MX250F128B has a myriad of peripheral features that makes this cheap little 28-pin 32-bit microcontroller extremely powerful. However, it does lack a digital-to-analog converter (DAC). A simple approach to digital-to-analog conversion is to use one of the PWM channels and then to use an RC low-pass filter at the output. However, there is another neat little feature of the device that can be exploited or rather utilized to obtain a rather crude DAC – the analog comparator module. Rather, the analog comparator reference module. The PIC32MX250F128B contains an internal voltage reference module that was created to be used as a reference voltage for the internal analog comparator module. However, it does allow you to output this reference voltage to an output pin. Analog voltage output with digital control? Sounds like a DAC. The voltage reference module is built off of a 16-tap resistor ladder network with two selectable ranges – from 0 to 0.67 CVREF or from 0.25 to 0.75 CVREF. CV...