Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 26th June 2009, 12:25 PM   #1
Default comparator not working

Hello everybody i am new on this forum and checked also topic related with comparator and didnt find any solution's so here i am posting my code ..please have a look and give me suggestion ...to work my comparator of 16F684.............

Rc0--analog input
Rc1--internal ref voltage
Rc4--comparator output.

using intenal comparator at 8mhz ..
not using any interrupt..of ocmparator

MAIN CODE

start
;***********************define pin direction, and initialization *************************



clrf PORTA
clrf PORTC
movlw 0x02
movwf PORTA ;;RA1 as supply power which is supply voltage for melexis
clrf ANSEL
movlw 0x05 ;enable comparator(one independent comparator enabled)
movwf CMCON0
bsf STATUS, RP0 ;change bank0 to bank1
bcf TRISC,RC3 ;set RC3 as output--WAKE-UP
bcf TRISC,RC4 ;set RC4 as output--comparator output
bcf TRISA,RA1 ;set RA1 as output--Power Supply to Switch
bsf TRISC,RC0 ;set RC0 as input---Switch analog output
bsf ANSEL, RC0 ;set RC0 as analog input
movlw 0x71 ;8Mhz
movwf OSCCON ;1-HTS stable bit and 1-internal clock
movlw 0x0F ;x0F ---max frequency
movwf OSCTUNE ;to select the max frequency tunning bit register
bcf STATUS, RP0
clrf INTCON




;************************************************* ****************************************

comparator:

bsf STATUS, RP0
movlw 0x86 ;internal voltage reference
movwf VRCON ;internal voltage reference set to(x86) 2,1875 volts
bcf STATUS, RP0 ;Cvref=((Vdd\4)+((Vrr[3:0]*Vdd)\32))


Check_comp:

btfsc CMCON0, C2OUT ;when the internal ext vtg is greater than 2,1875 v ;btfsc PORTC,RC4
goto WU_OFF ;than only we will get output from op-amp.
goto WU_ON

WU_ON:

bsf PORTC,RC3
goto Check_comp

WU_OFF:

bcf PORTC,RC3
goto Check_comp


please reply me as soon as possible.....request!!!!!!!!!!!!!!
Robinwithu is offline  
Reply

Tags
comparator, working

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
LCD not working (in known working circuit)?? Marks256 General Electronics Chat 7 22nd June 2009 04:21 AM
741 comparator - help asdad Electronic Projects Design/Ideas/Reviews 6 10th December 2008 03:23 PM
what comparator to use carmusic General Electronics Chat 14 22nd July 2008 01:09 PM
What does a comparator do ? jbelectric777 General Electronics Chat 6 9th April 2007 08:17 PM
Comparator YAN-1 Micro Controllers 5 26th June 2005 11:06 AM



All times are GMT. The time now is 11:30 PM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker