aniket_lad
Newbie level 1
subroutine in pic16f84
hi!
i am using pic16f84 for robotics purpose
in the program below i hav used 3 subroutines for go straight,left and right turn.
but whenever i run the program, only the subroutine placed first in the program is executed and it ignores rest two.
i hav used port b to conrtol relays and port a is used to take input from sensors.
please help me.
here is the program i hav written
;*****DECLARATION OF MICROCONTROLLER *********
PROCESSOR 16F84
#include "p16f84.inc"
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
;*******declaration of variables*********
Cblock 0x0C
con
endc
;*******program structure****************
org 0X00
goto Main
org 0X04
goto Main
;***************main pogram************
Main
banksel TRISB
clrf TRISB
banksel TRISA
movlw 0xff
movwf TRISA
Loop
banksel PORTA
movf PORTA,0
movwf con
btfsc con,3
call Rturn
banksel PORTA
movf PORTA,0
movwf con
btfsc con,1
call Front
banksel PORTA
movf PORTA,0
movwf con
btfsc con,2
call Lturn
banksel PORTB
clrf PORTB
goto Loop
Front
movlw 0xa0
banksel PORTB
movwf PORTB
return
Lturn
movlw 0x60
banksel PORTB
movwf PORTB
return
Rturn movlw 0x90
banksel PORTB
movwf PORTB
return
end
[/url]\]
hi!
i am using pic16f84 for robotics purpose
in the program below i hav used 3 subroutines for go straight,left and right turn.
but whenever i run the program, only the subroutine placed first in the program is executed and it ignores rest two.
i hav used port b to conrtol relays and port a is used to take input from sensors.
please help me.
here is the program i hav written
;*****DECLARATION OF MICROCONTROLLER *********
PROCESSOR 16F84
#include "p16f84.inc"
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
;*******declaration of variables*********
Cblock 0x0C
con
endc
;*******program structure****************
org 0X00
goto Main
org 0X04
goto Main
;***************main pogram************
Main
banksel TRISB
clrf TRISB
banksel TRISA
movlw 0xff
movwf TRISA
Loop
banksel PORTA
movf PORTA,0
movwf con
btfsc con,3
call Rturn
banksel PORTA
movf PORTA,0
movwf con
btfsc con,1
call Front
banksel PORTA
movf PORTA,0
movwf con
btfsc con,2
call Lturn
banksel PORTB
clrf PORTB
goto Loop
Front
movlw 0xa0
banksel PORTB
movwf PORTB
return
Lturn
movlw 0x60
banksel PORTB
movwf PORTB
return
Rturn movlw 0x90
banksel PORTB
movwf PORTB
return
end
[/url]\]