Sunday, May 29, 2011

Checking the DAC unit on another PIC

Using the same hardware setup as in the PIC12F1822 DAC test I dropped a PIC16F1827 into the breadboard and checked how its DAC would perform, given that the 12F1822 flunked horribly. The data below says it all. The 1827's DAC performed as it should 

DACCON1VOUT measured (volts)VOUT computed (volts)
0x000.0080
0x010.1130.106
0x020.2220.213
0x040.4350.427
0x080.8550.855
0x101.7041.710
0x1F3.3033.313

The firmware was as follows:

void InitRegisters()
{
  PORTA = 0;
  ANSELA = 0;
  TRISA = 0;
}

void main()
{
  InitRegisters();
  DACCON0 = 0b10100000;  // DAC enabled, DAC output available on DACOUT pin, Vdd as positive voltage source, Vss as negative voltage source
  DACCON1 = 0x10;        // change value of DACCON1 as required
  while(1);
}



After going over the firmware I used for the 1822 test I realized that I had inadvertently turned on the global weak pull-up--I cleared the WPUEN bit in OPTION_REG. Since all the bits of the individual weak pull-up register WPUA are high upon reset, the pull ups are then all enabled. This was the cause of the erroneous DAC output. So while pull ups may be enabled for other pins, if and when required, pull-up for RA0/DACOUT pin must be disabled if that pin will be used as DAC output.

After I burned the above firmware in the 1822, the DAC output instantly became as it ought to be, as the table below shows.

DACCON1VOUT measured (volts)VOUT computed (volts)
0x000.0280
0x010.1340.106
0x020.2390.213
0x040.4510.427
0x080.8740.855
0x101.7171.710
0x1F3.2923.313

4 comments:

  1. OKKKK THANKS I've got it.I'll try this tomorrow :)

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. I had several problems !

    First, the Pull Up on the Port A, so thank you for that :)

    And secondly, I was using the EasyPic card with a lot of electronics component, like Diode... so I had 0.7V, 0.6V falling.

    I use the internal oscillator, with a minimum of electronics components, I fix the problem with the pull up, and now it works fine :)

    ReplyDelete