Hi there ! I'm learning how to setup interrupts in PICs from
**broken link removed**
but, this is for 16f84 and I have f690, so far this is what I have done, almost copy of what is on the site, if you can guide me how interrupts work for 16f690 than Ill be thankful
What I don't understand is that how PIC can know (in tutorial not in my code) that INTCON,4 will enable RB0 while 4 can be for PORTA also, is this because we have enable globle interrupt ?
**broken link removed**
but, this is for 16f84 and I have f690, so far this is what I have done, almost copy of what is on the site, if you can guide me how interrupts work for 16f690 than Ill be thankful
Code:
list p=16f690
#include <p16f690.inc>
__CONFIG -_MCLRE_ON & _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT
ERRORLEVEL -302
UDATA
temp RES 1
display RES 1
count RES 1
;**************************STEUP THE CONSTANTS*******************************
org 0x05 ;this is where we come on power up and reset
;**************************INTRUPT ROUTINE************************************
movwf temp ;this and the lable Loop will run simultenously
;move w into f in case to there was someting in
;count(see first step of Loop)
incf count,f ;increase count by 1 and put result in count
movlw .10 ;load w with decimal 10
subwf count,w ;subtract count from w and place result in w
btfss STATUS,C ;if in above operation count<= w then carry bit
;is set, so check for that and skip next step
;if it is set
goto carry_on
goto clear
carry_on:
bcf INTCON,0x01 ;clear the INTF, just in case(read tuto. 11)
movfw temp ;move temp to w
retfie ;get out of intrupt loop (this will start over
; the whole INTRUPT LOOP again
clear:
clrf count ;set count to 0
bcf INTCON,0x01 ;clear INTF
retfie
;*****************************MAIN PROGRAMME************************
Main:
;*****************************SET UP THE INTRUP REGISTERS***********
bsf INTCON,0x07 ; set globel intrupt (tell PIC that we will use intrupts)
bsf INTCON,0x04 ;
bcf INTCON,0x01
;******************************SET UP THE PORTS**********************
bsf STATUS,RP0
movlw b'10000000'
movwf TRISC
bcf STATUS,RP0
;******************************NOW SEND THE VALUE OF COUNT TO PORTC**
Loop:
movf count,w
movwf PORTC
goto Loop
END
What I don't understand is that how PIC can know (in tutorial not in my code) that INTCON,4 will enable RB0 while 4 can be for PORTA also, is this because we have enable globle interrupt ?
Last edited: