PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu May 19, 2005 12:10 am |
|
|
It looks like you're trying to use the internal Vref with the comparators
in mode 6. However, according to the data sheet, the internal Vref is
only used in mode 2. I can confirm this. I ran the following test
program and it only worked in mode 2.
I used a 16F88 on a PicDem2-Plus board, and I set the trimpot for
an output voltage of 2.5v. When I ran the program below, and
moved the trimpot wheel back and forth very slightly, I got this output:
Quote: |
00
00
00
01
01
01
00
00
00
01
01
01
etc.
|
Code: | #include <16F88.h>
#fuses INTRC_IO, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=8000000)
#use RS232(baud=9600, xmit=PIN_B5, rcv=PIN_B2, ERRORS)
void main()
{
setup_oscillator(OSC_8MHZ);
setup_comparator(A0_VR_A1_VR); // Comparator mode 2
setup_vref(VREF_LOW | 12); // Set internal Vref = Vdd/2
while(1)
{
printf("%x\n\r", C1OUT); // Display C1 output every 1/2 second
delay_ms(500);
}
} |
|
|