DACCON1 | VOUT measured (volts) | VOUT computed (volts) |
0x00 | 0.008 | 0 |
0x01 | 0.113 | 0.106 |
0x02 | 0.222 | 0.213 |
0x04 | 0.435 | 0.427 |
0x08 | 0.855 | 0.855 |
0x10 | 1.704 | 1.710 |
0x1F | 3.303 | 3.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.
DACCON1 | VOUT measured (volts) | VOUT computed (volts) |
0x00 | 0.028 | 0 |
0x01 | 0.134 | 0.106 |
0x02 | 0.239 | 0.213 |
0x04 | 0.451 | 0.427 |
0x08 | 0.874 | 0.855 |
0x10 | 1.717 | 1.710 |
0x1F | 3.292 | 3.313 |
OKKKK THANKS I've got it.I'll try this tomorrow :)
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteI had several problems !
ReplyDeleteFirst, 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 :)
Glad everything's working :)
ReplyDelete