Hi Mat,
I corrected the typo "CMCOM.7", it should ofcource be "CMCON.7", PBP should give you an error.
I use SEROUT instead of LCDOUT, no big deal there exept the fact that you had "LCDOut, COUNTERT". Two things about that line, first - it's "syntax error", the comma shouldn't be there. Second - you have no ASCII operator such as #,DEC,HEX,BIN or whatever. This line would most of the time show garbage on your display. You should also change "DEFINE LCD_DBIT 4" to "DEFINE LCD_DBIT 0" since you use the lower half of PortB.
However, none of this LCDstuff should affect the operation of the Comparator. I got so puzzled by your problem that i just had to give it a testrun. I can now inform you that this code works just fine, i ran it on a 16F628 ten minutes ago. If you can't get this code to work, it just has to be a hardware problem.
Code:@ DEVICE PIC16F628,XT_OSC @ DEVICE PIC16F628,MCLR_ON @ DEVICE PIC16F628,BOD_OFF @ DEVICE PIC16F628,LVP_OFF @ DEVICE PIC16F628,CPD_OFF @ DEVICE PIC16F628,PROTECT_OFF DEFINE OSC 4 HULP1 VAR BIT HULP2 VAR BIT PULS VAR CMCON.7 COUNTERT VAR BYTE CMCON = 5 TRISA = %11111111 TRISB = %00000000 Clear BEGIN: IF PULS = 1 AND HULP1 = 0 Then HULP2 = 1 Else HULP2 = 0 EndIF IF PULS = 1 Then HULP1 = 1 Else HULP1 = 0 EndIF IF HULP2 = 1 Then COUNTERT = COUNTERT + 1 serout2 PortB.0,84,["CMP2 = ",BIN1 PULS, " HULP1 = ",BIN1 HULP1] serout2 PortB.0,84,[" HULP2 = ",BIN1 HULP2, " COUNTERT = ",DEC3 COUNTERT, 13, 10] PAUSE 100 GoTo BEGIN
/Ingvar
Oops, crap, not that it matters much but i just realized that i made a mistake in my last post. Your code couldn't be reduced to what i suggested. I read the first IF-THEN statement wrong. Sorry.




Bookmarks