(Start of code. ) and
only some errors remaining. posting my file againCan you please tell what exactly is the error. Is it indentation or spelling. I'm sorry but I'm totally new to the synatx
;pic16f877a
list p=16F877A
#include <p16F877A.inc>
;-------------------------------------------------------------
;declaring variables
c1 equ 19h
c2 equ 69h
c3 equ 37h
;---------------------------------------------------------------
org 0
goto START
; Initializing subroutines
; subrotine to change banks
bank0 BCF STATUS,2 ;PORTA
BCF STATUS,3
return
bank1 BCF STATUS,2 ;TRISA
BSF STATUS,3
return
bank2 BSF STATUS,2 ;TRISB
BCF STATUS,3
return
bank3 BSF STATUS,2 ;PORTB
BSF STATUS,3
return
;---------------------------------------------------------
;---------------------------------------------------------
; subroutine to call Alarm
alarm call bank3
BSF PORTB,2
call delay_2sec
goto MAIN
return
;--------------------------------------------------------
; subroutine to call motor
motor call bank3
BSF PORTB,5
call delay_3sec
return
;-------------------------------------
; subroutine for 2 seconds delay
delay_2sec MOVLW d'80' ; adding value of 80 in decimals to the working register
MOVWF c3 ; adding the stored value into Wreg
loop23 MOVLW d'200'
MOVWF c2
loop22 MOVLW d'250'
MOVWF c1
loop2 nop
nop
decfsz c1,1
goto loop2
decfsz c2,1
goto loop22
decfsz c3,1
goto loop23
return
;-------------------------------------------------------------
; subroutine for 3 second delay
delay_3sec MOVLW d'120'
MOVWF c3
loop33 MOVLW d'200'
MOVWF c2
loop32 MOVLW d'250'
MOVWF c1
loop3 nop
nop
decfsz c1,1
goto loop3
decfsz c2,1
goto loop32
decfsz c3,1
goto loop33
return
;-----------------------------------------------------------------------------------------
; subroutine for entering password for user
enter_password call bank3 ; call bank in which PORTB is present
BTFSS PORTB,0 ; check if B0 is set, if skip next instruction
call alarm ; perform this instruction if B0 is not set
BTFSS PORTB,0 ; check if B0 is set, if yes then skip next instruction
call alarm ; call alarm if B0 is not set
call bank0 ; call bank in which PORTA is present
BTFSS PORTA,1 ; check 3rd digit
call alarm ; call alarm if digit not correct
BTFSS PORTA,4 ; check fourth ddigit
call alarm ; call alarm if digit not correct
BTFSS PORTA,4 ; check fifth digit
call alarm ; call alarm if digit is not correct
BTFSS PORTA,5 ; check sixth digit
call alarm ; call alarm if digit not correct
BTFSS PORTA,5 ; check seventh digit
call alarm ; call alarm if digit not correct
BTFSS PORTA,6 ; check eight digit
call alarm ; call alarm if digit not correct
BTFSS PORTA,0 ; check ninth digit
call alarm ; call alarm if digit not correct
BTFSS PORTA,2 ; check tenth digit
call alarm ;call alarm if digit not correct
return
;---------------------------------------------------------------------------
; MAIN functions to be performed in the program
; defining inputs and outputs
START
call bank1 ; calling bank in which TRISA is present
clrF TRISA ; setting inputs on all pins of TRISA
call bank2 ; calling bank in which TRISB is present
BSF TRISB,0 ; setting input on pin0 of TRISB
BCF TRISB,2 ; setting output on pin2 of TRISB
BCF TRISB,5 ; setting output on pin5 of TRISB
MAIN call enter_password ; call the subroutine and check the password
call motor ; if password correct on motor
goto enter_password ; user able to enter password again
goto MAIN ; endless loop
END ; end of programme
jazakallah. may Allah bless youThis works
Code:;pic16f877a list p=16F877A #include <p16F877A.inc> ;------------------------------------------------------------- ;declaring variables c1 equ 19h c2 equ 69h c3 equ 37h ;--------------------------------------------------------------- org 0 goto START ; Initializing subroutines ; subrotine to change banks bank0 BCF STATUS,2 ;PORTA BCF STATUS,3 return bank1 BCF STATUS,2 ;TRISA BSF STATUS,3 return bank2 BSF STATUS,2 ;TRISB BCF STATUS,3 return bank3 BSF STATUS,2 ;PORTB BSF STATUS,3 return ;--------------------------------------------------------- ;--------------------------------------------------------- ; subroutine to call Alarm alarm call bank3 BSF PORTB,2 call delay_2sec goto MAIN return ;-------------------------------------------------------- ; subroutine to call motor motor call bank3 BSF PORTB,5 call delay_3sec return ;------------------------------------- ; subroutine for 2 seconds delay delay_2sec MOVLW d'80' ; adding value of 80 in decimals to the working register MOVWF c3 ; adding the stored value into Wreg loop23 MOVLW d'200' MOVWF c2 loop22 MOVLW d'250' MOVWF c1 loop2 nop nop decfsz c1,1 goto loop2 decfsz c2,1 goto loop22 decfsz c3,1 goto loop23 return ;------------------------------------------------------------- ; subroutine for 3 second delay delay_3sec MOVLW d'120' MOVWF c3 loop33 MOVLW d'200' MOVWF c2 loop32 MOVLW d'250' MOVWF c1 loop3 nop nop decfsz c1,1 goto loop3 decfsz c2,1 goto loop32 decfsz c3,1 goto loop33 return ;----------------------------------------------------------------------------------------- ; subroutine for entering password for user enter_password call bank3 ; call bank in which PORTB is present BTFSS PORTB,0 ; check if B0 is set, if skip next instruction call alarm ; perform this instruction if B0 is not set BTFSS PORTB,0 ; check if B0 is set, if yes then skip next instruction call alarm ; call alarm if B0 is not set call bank0 ; call bank in which PORTA is present BTFSS PORTA,1 ; check 3rd digit call alarm ; call alarm if digit not correct BTFSS PORTA,4 ; check fourth ddigit call alarm ; call alarm if digit not correct BTFSS PORTA,4 ; check fifth digit call alarm ; call alarm if digit is not correct BTFSS PORTA,5 ; check sixth digit call alarm ; call alarm if digit not correct BTFSS PORTA,5 ; check seventh digit call alarm ; call alarm if digit not correct BTFSS PORTA,6 ; check eight digit call alarm ; call alarm if digit not correct BTFSS PORTA,0 ; check ninth digit call alarm ; call alarm if digit not correct BTFSS PORTA,2 ; check tenth digit call alarm ;call alarm if digit not correct return ;--------------------------------------------------------------------------- ; MAIN functions to be performed in the program ; defining inputs and outputs START call bank1 ; calling bank in which TRISA is present clrF TRISA ; setting inputs on all pins of TRISA call bank2 ; calling bank in which TRISB is present BSF TRISB,0 ; setting input on pin0 of TRISB BCF TRISB,2 ; setting output on pin2 of TRISB BCF TRISB,5 ; setting output on pin5 of TRISB MAIN call enter_password ; call the subroutine and check the password call motor ; if password correct on motor goto enter_password ; user able to enter password again goto MAIN ; endless loop END ; end of programme
The following code can be simplified:
-------------------
[CODE
]; subrotine to change banks
bank0 BCF STATUS,2 ;PORTA
BCF STATUS,3
return
bank1 BCF STATUS,2 ;TRISA
BSF STATUS,3
return
bank2 BSF STATUS,2 ;TRISB
BCF STATUS,3
return
bank3 BSF STATUS,2 ;PORTB
BSF STATUS,3
return
[/CODE]
-------------------
Look at figure 2-3 in the datasheet and note that PORTA and PORTB are in the same BANK (BANK 0)
And TRISA and TRISB are in the same BANK (BANK 1)
PORTB and TRISB are repeated in other banks, but that does not affect their selection.
There is a simple assembler directive for selecting BANKs.
BANKSEL PORTA will select BANK0, where both PORTA and PORTB are located.
You could use
BANKSEL PORTB which will give the exact same result, selecting BANK0.
Similarly, to select the TRIS registers, use BANKSEL TRISA.
Using BANKSEL is much simpler and makes the ASM file much simpler to read.
JimB
how do i do itJust re-itterate.. Because you missed the org 0 and the goto start, it was compiling relocatable code.
Those are not errors.... The error is on the line
"Language plugin exception"
In your build directory find the Debug folder then look at the "assignment1.err" file post it here if you like.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?