ahem... did you test this code? i do not think it will work properly. where do you set the interrupts? You need to enable intcon, gie and also enable intcon,rb0, and also clear the interrupt flag of rbo/int interrupt every time before retfie to re-enable the interrupt. I did not compile the code and i do not really know if you have more errors.
Also, here are some tips: First, do not use hex numbers to set registers. look:
MOVLW 0x07 ; Turn comparators off and enable pins (PORTA) for I/O functions
MOVWF CMCON
and this:
MOVLW b'00000111' ; Turn comparators off and enable pins (PORTA) for I/O functions
MOVWF CMCON
This is easier to understand what each bit is.
-------------------------------------------------------------
Also, it is very very important to keep all ports as inputs if they are not used, during prototyping time. That is because during prototyping, you may make a mistake and connect VCC or GND to an output PIN. If you connect VCC to a LOW output, then the pin (and maybe the PIC) will be destroyed. When you move from prototyping to design, then all unused pins should be declared as outputs, because input pins must not left floating.
-------------------------------------------------------------
finally, learn how to use macros to change banks. look this:
BSF STATUS,RP0
BCF STATUS,RP1 ; Bank 1
and this:
BANK1
which one is better? You need of course to declare a macro with name BANK1 somewhere in the beginning. I usually add those macros in the header file. Here is a macro to switch to bank 1:
Bank1 macro
bcf status,rp1
bsf status,rp0
endm
You can now switch to Bank1 simply by writing "bank1"... Nice eh?
-------------------------------------------------------------
Same declare basic flags like zero, carry and dcarry :
#define carry status,c ; STATUS register
#define dcarry status,dc
#define zero status,z
-------------------------------------------------------------
As a matter of fact, this is what i have add at the end of file PIC16F88.inc:
; Macros
Bank0 macro
bcf status,rp1
bcf status,rp0 ; BANK0 (Data Memory)
;bcf status,irp
endm
Bank1 macro
bcf status,rp1
bsf status,rp0 ; BANK1 (Data Memory)
;bcf status,irp
endm
Bank2 macro
bsf status,rp1
bcf status,rp0 ; BANK1 (Data Memory)
;bsf status,irp
endm
Bank3 macro
bsf status,rp1
bsf status,rp0 ; BANK1 (Data Memory)
;bsf status,irp
endm
; Definitions of Bits
#define carry status,c ; STATUS register
#define dcarry status,dc
#define zero status,z
The schematic is ok
