A
Ankur
Guest
Hi all,
Someone please help me out..
Please see the program below which is working the way i don't want it
to.
I've interfaced 5leds to PORTA( i'v used a pull-up in PA4 pin) and am
trying to work out a binary counting on the 5leds.The trigger to count
is being given by RB<7:4> pin state change. So, whenever i change the
state of any of RB<7:4>, i should see a count UP on the leds(say it
was 00001 earlier, i should see 00010 on changing the state of
RB<7:4>pins)
But the problem i am facing is that the program comes back into the
Main Loop inspite of a "Wait Loop" provided. I don't know but after
the first interrupt, the program runs back into Main.
b'bye and thnx
******************************************PROGRAM*******************************
#include "p16f84a.inc"
count equ 0Ch ;First counter for our
delay loops
bank0 macro
bcf STATUS,RP0
endm
bank1 macro
bsf STATUS,RP0
endm
org 0x00
goto Main
org 0x04
goto ISR
org 0x10
Main
bank1
clrf TRISA ; portA configured as OUTPUT
movwf 0xff
movwf TRISB; portB configured as INPUT
bank0
movlw 0xff
movwf PORTA
movlw 0x04
movwf count ; count=4
bank1
movlw b'00000111'
movwf OPTION_REG ; for timer prescalar 1:256
;
; ;configure INTCON
;
bsf INTCON,RBIE ;RB port change Interrupt Enable bit
bsf INTCON,GIE ; Enable interrupts!!
loop
nop
goto loop ; wait state
ISR
bank0
;we inc. 'count' every time ISR is executed & send it on PORTA to
verify.
incf count,f ;when i used "incf PORTA"
********************************************
movf count,w ;instead of these 3
commands*****************************************
movwf PORTA ;it did not
work.****************************************************
;
bcf INTCON,RBIF ; IMPORTANT - clear back the interrupt flag
BSF INTCON,GIE ; IMPORTANT! - re-enable the interrupts
return
goto loop
end
Someone please help me out..
Please see the program below which is working the way i don't want it
to.
I've interfaced 5leds to PORTA( i'v used a pull-up in PA4 pin) and am
trying to work out a binary counting on the 5leds.The trigger to count
is being given by RB<7:4> pin state change. So, whenever i change the
state of any of RB<7:4>, i should see a count UP on the leds(say it
was 00001 earlier, i should see 00010 on changing the state of
RB<7:4>pins)
But the problem i am facing is that the program comes back into the
Main Loop inspite of a "Wait Loop" provided. I don't know but after
the first interrupt, the program runs back into Main.
b'bye and thnx
******************************************PROGRAM*******************************
#include "p16f84a.inc"
count equ 0Ch ;First counter for our
delay loops
bank0 macro
bcf STATUS,RP0
endm
bank1 macro
bsf STATUS,RP0
endm
org 0x00
goto Main
org 0x04
goto ISR
org 0x10
Main
bank1
clrf TRISA ; portA configured as OUTPUT
movwf 0xff
movwf TRISB; portB configured as INPUT
bank0
movlw 0xff
movwf PORTA
movlw 0x04
movwf count ; count=4
bank1
movlw b'00000111'
movwf OPTION_REG ; for timer prescalar 1:256
;
; ;configure INTCON
;
bsf INTCON,RBIE ;RB port change Interrupt Enable bit
bsf INTCON,GIE ; Enable interrupts!!
loop
nop
goto loop ; wait state
ISR
bank0
;we inc. 'count' every time ISR is executed & send it on PORTA to
verify.
incf count,f ;when i used "incf PORTA"
********************************************
movf count,w ;instead of these 3
commands*****************************************
movwf PORTA ;it did not
work.****************************************************
;
bcf INTCON,RBIF ; IMPORTANT - clear back the interrupt flag
BSF INTCON,GIE ; IMPORTANT! - re-enable the interrupts
return
goto loop
end