Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Password door lock using pic16f877a, using assembly

Status
Not open for further replies.
Ive done all of what all of just recommended but these error show up constantly now

Warning[205] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 2 : Found directive in column 1. (list)
Error[150] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 25 : Labels must be defined in a code or data section when making an object file
Error[152] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 25 : Executable code and data must be defined in an appropriate section
Error[152] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 26 : Executable code and data must be defined in an appropriate section
Error[152] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 27 : Executable code and data must be defined in an appropriate section
Error[150] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 29 : Labels must be defined in a code or data section when making an object file
Error[152] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 29 : Executable code and data must be defined in an appropriate section
Error[152] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 30 : Executable code and data must be defined in an appropriate section
Error[152] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 31 : Executable code and data must be defined in an appropriate section
 
There is only one STATUS register. It can be accessed from any bank. (So a bank select is not required before accessing it.) This also applies to some other registers. For example the FSR. See page 17 of the PIC16F877A datasheet.

Re your post #21. Post the list file so we can see the source code for the lines with errors. Use the code tags as I used in post #12.
Paste the list file between
Code:
 (Start of code. ) and
(End of code.) tags.

That did not display as I wanted it as it interpreted the code tags.
The start of code tag is open square bracket, the word code, close square bracket.
The end of code tag is open square bracket, /code, close square bracket.

Les.
 
Last edited:
ive changed much things but it is still not removing. any other suggesstion?


;pic16f877a
list p=16F877A
#include <p16F877A.inc>
;-------------------------------------------------------------
;declaring variables

STATUS equ 09h

;PORTA equ 63h
;TRISA equ 93h
;PORTB equ 68h
;TRISB equ 52h

c1 equ 19h
c2 equ 69h
c3 equ 37h
;---------------------------------------------------------------

; 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
;---------------------------------------------------------

; defining inputs and outputs
call bank1 ; calling bank in which TRISA is present
BSF 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

;---------------------------------------------------------

; 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

loop3 MOVLW d'200'
MOVWF c2

loop2 MOVLW d'250'
MOVWF c1

loop nop
nop
decfsz c1,1
goto loop

decfsz c2,1
goto loop2

decfsz c3,1
goto loop3

return
;-------------------------------------------------------------
; subroutine for 3 second delay

delay_3sec MOVLW d'120'
MOVWF c3

loop3 MOVLW d'200'
MOVWF c2

loop2 MOVLW d'250'
MOVWF c1

loop nop
nop
decfsz c1,1
goto loop

decfsz c2,1
goto loop2

decfsz c3,1
goto loop3

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

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
 
Can you please tell what exactly is the error. Is it indentation or spelling. I'm sorry but I'm totally new to the synatx
only some errors remaining. posting my file again


Executing: "E:\MPASM Suite\MPASMWIN.exe" /q /p16F877A "assignment1.asm" /l"assignment1.lst" /e"assignment1.err" /o"assignment1.o" /d__DEBUG=1
Error[115] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 9 : Duplicate label ("STATUS" or redefining symbol that cannot be redefined)
Message[302] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 43 : Register in operand not in bank 0. Ensure that bank bits are correct.
Error[128] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 43 : Missing argument(s)
Message[302] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 46 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 47 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 48 : Register in operand not in bank 0. Ensure that bank bits are correct.
Error[116] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 96 : Address label duplicated or different in second pass (loop3)
Error[116] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 99 : Address label duplicated or different in second pass (loop2)
Error[116] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 102 : Address label duplicated or different in second pass (loop)
Warning[207] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 144 : Found label after column 1. (MAIN)
Halting build on first failure as requested.
 

Attachments

  • assignment1.asm
    4.3 KB · Views: 296
This 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
 
This 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
jazakallah. may Allah bless you
 
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
 
these errors are still showing. ive just copied rogers

Message[302] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 138 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 141 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 142 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] C:\USERS\HP\DESKTOP\PASWORD_LOCK\ASSIGNMENT1.ASM 143 : Register in operand not in bank 0. Ensure that bank bits are correct.
A language-plugin exception occurred and was logged.
 
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
 
just four errors remaining. please can anyone help.
1648130355724.png
 
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.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top