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

16F628A
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
16f628User
Guest







PostPosted: Sun Jul 13, 2008 6:49 pm     Reply with quote

Ok, thanks I will check them later

Any example on the comparator please?
dyeatman



Joined: 06 Sep 2003
Posts: 1985
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Jul 13, 2008 7:14 pm     Reply with quote

To start trying to code this it would be good for you to undertstand how it would work.

Here is a link to a Microchip Appnote with info about how it could be implemented.

http://ww1.microchip.com/downloads/en/devicedoc/41215B.pdf

Also, see this:
http://www.ccsinfo.com/forum/viewtopic.php?t=22016&

Dave
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jul 13, 2008 7:15 pm     Reply with quote

See this CCS example file:
Quote:
c:\program files\picc\examples\ex_comp.c

However, your version will be buggy for the setup_comparator() function:
http://www.ccsinfo.com/forum/viewtopic.php?t=31293
16f628User
Guest







PostPosted: Mon Jul 14, 2008 2:57 am     Reply with quote

Got it to work:

Code:
#include <16F628A.h>
#use delay (clock=4000000)
#fuses INTRC_IO, NOWDT, NOPUT, NOBROWNOUT, NOMCLR, NOLVP, NOPROTECT

short safe_conditions=TRUE;

#INT_COMP
void isr()  {

   safe_conditions=FALSE;
   output_high(PIN_B0);
   output_low(PIN_B1);
   //printf("WARNING!!  Voltage level is above 3.6 V.   \r\n");
}


main()   
{
   setup_comparator(A3_VR_A2_VR);
   setup_vref(VREF_HIGH|15);
   enable_interrupts(INT_COMP);
   enable_interrupts(GLOBAL);


   while(TRUE)
   {
      if(safe_conditions)
      {
         output_high(PIN_B1);
         output_low(PIN_B0);

         //printf("Voltage level is below 3.6 V.              \r\n");
      }
      safe_conditions=TRUE;
      delay_ms(10);
   }
}



Can't we change "setup_vref(VREF_HIGH|15);" on a loop to make some kind of AD?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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