CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

16F88 Comparator Problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu May 19, 2005 12:10 am     Reply with quote

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);
  }
   
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group