sarge
Full Member level 3
- Joined
- Dec 29, 2009
- Messages
- 187
- Helped
- 57
- Reputation
- 114
- Reaction score
- 56
- Trophy points
- 1,308
- Activity points
- 2,170
Hi, i have some problems with comparator in PIC16f877a
My code
This code works fine in proteus, but doesn't work in hardware. What is wrong here?
Compiler - Hi-tech PICC 9.71.
Thanks for advance.
My code
Code:
#include <htc.h>
#include <stdio.h>
#define _XTAL_FREQ 4000000
__CONFIG(WDTDIS & UNPROTECT & LVPDIS & HS & BOREN);
void main()
{
CMCON = 0x02;
ADCON0 = 0xFF;
ADCON1 = 0xFF;
TRISB1 = 0;
TRISB2 = 0;
TRISA0 = 1;
TRISA3 = 1;
RB1 = 0;
RB2 = 1;
GIE = 1;
PEIE = 1;
CMIE = 1;
while(1)
{
}
}
void interrupt isr()
{
if (CMIF)
{
RB2 = !RB2;
CMCON = 0x02;
CMIF = 0;
}
}
This code works fine in proteus, but doesn't work in hardware. What is wrong here?
Compiler - Hi-tech PICC 9.71.
Thanks for advance.