Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC16f877a comparator module

Status
Not open for further replies.

sarge

Full Member level 3
Full Member level 3
Joined
Dec 29, 2009
Messages
187
Helped
57
Reputation
114
Reaction score
56
Trophy points
1,308
Visit site
Activity points
2,170
Hi, i have some problems with comparator in PIC16f877a

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.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top