williB
New Member
This program works but the response is slow
like a half second when i switch RB4 between 5v and ground ?
its running at 1.25 Mhz Fosc
i'm not complaining really , i just thought it would respond a little faster
any ideas on how to speed up the response time?
like a half second when i switch RB4 between 5v and ground ?
its running at 1.25 Mhz Fosc
i'm not complaining really , i just thought it would respond a little faster
any ideas on how to speed up the response time?
Code:
LIST P=16F877A
include "P16F877A.inc"
errorlevel -302 ;Eliminate bank warning
; program tests RB4 interrupt on change feature
; the pulse is a short pulse
TEMP EQU 0x20
COUNT EQU 0X21
ADON EQU 0X00
ADIF EQU 0X06
GO_DONE EQU 0X02
TMR2ON EQU 0X02
TMR2IF EQU 0X01
RP0 EQU 0x05
RP1 EQU 0x06
W EQU H'0000'
F EQU H'0001'
RB4 equ 0x04
;----- Register Files------------------------------------------------------
INDF EQU H'0000'
TMR0 EQU H'0001'
PCL EQU H'0002'
STATUS EQU H'0003'
FSR EQU H'0004'
PORTA EQU H'0005'
PORTB EQU H'0006'
PORTC EQU 0x0007
PORTD EQU 0x0008
PORTE EQU 0x0009
PCLATH EQU H'000A'
INTCON EQU H'000B'
RBIF EQU H'0000'
PIR1 EQU H'000C'
PIR2 EQU H'000D'
TMR1L EQU H'000E'
TMR1H EQU H'000F'
T1CON EQU H'0010'
TMR2 EQU H'0011'
T2CON EQU H'0012'
CCPR1L EQU H'0015'
CCPR1H EQU H'0016'
CCP1CON EQU H'0017'
RCSTA EQU H'0018'
TXREG EQU H'0019'
RCREG EQU H'001A'
ADRESH EQU H'001E'
ADCON0 EQU H'001F'
OPTION_REG EQU H'0081'
RBPU EQU 0x0007
TRISA EQU H'0085'
TRISB EQU H'0086'
TRISC EQU 0x0087
TRISD EQU 0x0088
TRISE EQU 0x0089
PIE1 EQU H'008C'
PCON EQU H'008E'
PR2 EQU H'0092'
TXSTA EQU H'0098'
SPBRG EQU H'0099'
EEDATA EQU H'010C'
ANSEL EQU H'009B'
CMCON EQU H'009C'
EECON2 EQU H'018D'
ADRESL EQU H'009E'
ADCON1 EQU H'009F'
org 0x00 ; Reset Vector
goto START ;
org 0x04 ; int vector
goto ISR
START
clrf PORTA ;B0
clrf PORTB ;B0
clrf PORTC ;B0
clrf PORTD ;B0
CLRF STATUS ;B0
;B0
Banksel TRISA ;B1
CLRF TRISA ;B1
clrf TRISB ;B1
CLRF TRISC ;B1
CLRF TRISD ;B1
bsf OPTION_REG,RBPU ;B1
;B1
BCF STATUS ,RP0 ;B0
LOOP2 movlw 0x00 ;clear PORTD while no Interrupt
movwf PORTD
goto LOOP2 ; Wait for int and loop forever
ISR btfss INTCON, RBIF ;PortB Interrupt?
goto other_int ;Other interrupt
;btfsc PORTB, RB4 ; Wide pulse check for rising edge
;goto clear_RBINTF ;Falling edge clear portB int flag
movLw 0xFF ; Blink portD LEDs on Interrupt
Movwf COUNT ;
LOOP MOVWF PORTD ;
decfsz COUNT ;
goto LOOP ;
clear_RBINTF
movf PORTB,1 ;read PORTB (to itself) to end
;mismatch condition
bcf INTCON,RBIF ;Clear RB interrupt flag.
retfie ;RETurn From IntErrupt
other_int ;was it another interrupt?
retfie ;return from int
END