eyan23
Newbie level 5
i have done it for my fyp.but something was wrong. can anyone tell me what wrong with my coding? it my first time joining the forum and doing programming in MPLAB. all the advise i will appreciate. thanks..
;TITLE: AVAILABLE PARKING SPACE
;PIC TYPE: 16F84A
;OSCILLATOR SPEED: 4 MHz
LIST p=16F84A
#include "P16F84A.INC"
ORG OCH
TEMP1 RES 1
TEMP2 RES 1
;***********PORT A: ALL INPUT**********
;#DEFINE RX4 PORTA,0
;#DEFINE RX3 PORTA,1
;#DEFINE RX2 PORTA,2
;#DEFINE RX1 PORTA,3
;#DEFINE ENTR PORTA,4
;**********PORT B: ALL OUTPUT**********
;#DEFINE 1a PORTB,0
;#DEFINE 1b PORTB,1
;#DEFINE 1c PORTB,2
;#DEFINE 1d PORTB,3
;#DEFINE 1e PORTB,4
;#DEFINE 1f PORTB,5
;#DEFINE 1g PORTB,6
;#DEFINE PAO STATUS,5
;#DEFINE EXIT PORTB,7
;DRAWER1 EQU 3DH
;**********MAIN PROGRAM STARTS HERE**********
INIT CLRF PORTA
CLRF PORTB
BSF PAO
MOVLW b'11111'
MOVWF TRISA
; MOVLW b'00000000'
; MOVWF TRISB
BCF PAO
;*********START*********
MOVLW 04H
MOVWF DRAWER1
CHECK BTFSC ENTR
GOTO NEXT
DECF DRAWER1,1
GOTO DISPLAY
NEXT BTFSC EXIT
GOTO CHECK
INCF DRAWER1,1
GOTO DISPLAY
GOTO CHECK
DISPLAY ORG 0000H
MOV PSW,#00H
MOV A,#00H
SETB C
MOV R3,#70H
MOV R4,#70H
X1: MOV P2,#01H ; P2 DISPLAY SELECT
MOV P0,#00H ; P0 SEGMENTS
ACALL DEL
MOV P0,#44H
ACALL DEL
MOV P2,#02H
MOV P0,#00H
ACALL DEL
MOV P0,#3DH
ACALL DEL
MOV P2,#04H
MOV P0,#00H
ACALL DEL
MOV P0,#7CH
ACALL DEL
MOV P2,#08H
MOV P0,#00H
ACALL DEL
MOV P0,#4EH
ACALL DEL
JNC X2
DJNZ R3,X3
AJMP X4
X3: MOV P2,#80H
MOV P0,#00H
ACALL DEL
MOV P0,#7AH
ACALL DEL
AJMP X5
X2: DJNZ R4,X5
CPL C
MOV R4,#70H
AJMP X5
X4: MOV R3,#70H
CPL C
X5: MOV P2,#40H
MOV P0,#00H
ACALL DEL
MOV P0,#7BH
ACALL DEL
MOV P2,#20H
MOV P0,#00H
ACALL DEL
MOV P0,#54H
ACALL DEL
MOV P2,#10H
MOV P0,#00H
ACALL DEL
MOV P0,#7FH
ACALL DEL
AJMP X1
DEL: MOV B,#7FH
DJNZ B,$
ret
end
;TITLE: AVAILABLE PARKING SPACE
;PIC TYPE: 16F84A
;OSCILLATOR SPEED: 4 MHz
LIST p=16F84A
#include "P16F84A.INC"
ORG OCH
TEMP1 RES 1
TEMP2 RES 1
;***********PORT A: ALL INPUT**********
;#DEFINE RX4 PORTA,0
;#DEFINE RX3 PORTA,1
;#DEFINE RX2 PORTA,2
;#DEFINE RX1 PORTA,3
;#DEFINE ENTR PORTA,4
;**********PORT B: ALL OUTPUT**********
;#DEFINE 1a PORTB,0
;#DEFINE 1b PORTB,1
;#DEFINE 1c PORTB,2
;#DEFINE 1d PORTB,3
;#DEFINE 1e PORTB,4
;#DEFINE 1f PORTB,5
;#DEFINE 1g PORTB,6
;#DEFINE PAO STATUS,5
;#DEFINE EXIT PORTB,7
;DRAWER1 EQU 3DH
;**********MAIN PROGRAM STARTS HERE**********
INIT CLRF PORTA
CLRF PORTB
BSF PAO
MOVLW b'11111'
MOVWF TRISA
; MOVLW b'00000000'
; MOVWF TRISB
BCF PAO
;*********START*********
MOVLW 04H
MOVWF DRAWER1
CHECK BTFSC ENTR
GOTO NEXT
DECF DRAWER1,1
GOTO DISPLAY
NEXT BTFSC EXIT
GOTO CHECK
INCF DRAWER1,1
GOTO DISPLAY
GOTO CHECK
DISPLAY ORG 0000H
MOV PSW,#00H
MOV A,#00H
SETB C
MOV R3,#70H
MOV R4,#70H
X1: MOV P2,#01H ; P2 DISPLAY SELECT
MOV P0,#00H ; P0 SEGMENTS
ACALL DEL
MOV P0,#44H
ACALL DEL
MOV P2,#02H
MOV P0,#00H
ACALL DEL
MOV P0,#3DH
ACALL DEL
MOV P2,#04H
MOV P0,#00H
ACALL DEL
MOV P0,#7CH
ACALL DEL
MOV P2,#08H
MOV P0,#00H
ACALL DEL
MOV P0,#4EH
ACALL DEL
JNC X2
DJNZ R3,X3
AJMP X4
X3: MOV P2,#80H
MOV P0,#00H
ACALL DEL
MOV P0,#7AH
ACALL DEL
AJMP X5
X2: DJNZ R4,X5
CPL C
MOV R4,#70H
AJMP X5
X4: MOV R3,#70H
CPL C
X5: MOV P2,#40H
MOV P0,#00H
ACALL DEL
MOV P0,#7BH
ACALL DEL
MOV P2,#20H
MOV P0,#00H
ACALL DEL
MOV P0,#54H
ACALL DEL
MOV P2,#10H
MOV P0,#00H
ACALL DEL
MOV P0,#7FH
ACALL DEL
AJMP X1
DEL: MOV B,#7FH
DJNZ B,$
ret
end
Last edited: