I have got a PIR sensor, I amplified it, and now I want to use the comparator inside the 16f88. The reference signal is 5 volt with a variable resistance. Somehow it doesn't work, when lowering the reference voltage PORTB still gives a high output.. But maybe I'm just making a very stupid mistake?
Thanks guys, I'll try it right away. Yes it's just a test, later it should set a relay and stuff, but I first wanted to get this straight so later on I could be sure nothing is wrong with this part of the code.
In the finished version, since you used the W and STATUS registers, don't forget to save their context at the beginning of INR and restore them prior to RETFIE.
Main
banksel TRISA
movlw b'11100111'
movwf TRISA
clrf TRISB <- you wont need this
; movwf TRISB <- if you will not use the PORTB then you dont need to setup it's direction
banksel PORTB
movlw b'11111111' <- high output in PORTB is because of this
movwf PORTB <-----------------------'
banksel CMCON
movlw b'00000101'
movwf CMCON
banksel PIE2
bsf PIE2,CMIE
banksel INTCON
bsf INTCON,PEIE
bsf INTCON,GIE
LOOP
goto LOOP ; The program will stuck here 4ever, instead of runing the port value for your control logic
INR
banksel PORTB
movlw b'00000000'
movwf PORTB ; <-- maybe you need this? (motion is right !!)
goto INR
RETFIE
End
If you don't know how to program in assembler why don't you try C ??
You have many C compilers for the Pic Family for the 16XXX you need the MPLAB C16 and obviously the IDE too
Anyway the code is a little bit confuse since i don't know what you really whant to make.