Sunday, May 29, 2011

DAC using the FVR as voltage source

Continuing with the DAC tests over the last two days, I wanted to see the DAC using the internal fixed voltage reference instead of VDD. This would allow VDD to vary (with the condition that VDD > FVR output) without affecting the DAC operation. So I loaded the PIC18F1822 with the firmware below. Note that the internal oscillator frequency has been set to 31kHz to provide a delay between increment/decrement of DACCON1 value.

void InitRegisters()
  PORTA = 0;
  ANSELA = 0;
  TRISA = 0;
  OSCCON = 0b1000;            // run internal oscillator at 31kHz LF
  FVRCON = 0b10001000;        // enable fixed voltage reference for DAC, set gain = 2 to give a ref volt of 2.048V

void main() 
  DACCON0 = 0b10101000;       // DAC enabled, DAC output available on DACOUT pin, FVR as positive voltage source
  DACCON1 = 0x1F;  
    while (DACCON1-- >1);     // go from DACCON1 = 31 to DACCON1 = 0 
    while (DACCON1++ < 30);   // go from DACCON1 = 1 to DACCON1 = 31

And here are the oscilloscope readings:

No comments:

Post a Comment