| View previous topic :: View next topic |
| Author |
Message |
16f628User Guest
|
|
Posted: Sun Jul 13, 2008 6:49 pm |
|
|
Ok, thanks I will check them later
Any example on the comparator please? |
|
 |
dyeatman
Joined: 06 Sep 2003 Posts: 1985 Location: Norman, OK
|
|
 |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
 |
16f628User Guest
|
|
Posted: Mon Jul 14, 2008 2:57 am |
|
|
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? |
|
 |
|