PROCESSOR 16F877A
#INCLUDE<P16F877A.INC>
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _WRT_OFF & _LVP_OFF &_CPD_OFF
TAM EQU 20H
DEM EQU 21H
DEM1 EQU 22H
DEM2 EQU 23H
DEM3 EQU 25H
DEM4 EQU 26H
KQ EQU 24H
ORG 0000H
BCF STATUS,6
BSF STATUS,5
CLRF TRISD
MOVLW B'00110000'
MOVWF TRISB
BCF STATUS,5
CLRF PORTB
CLRF PORTD
CLRF TMR0
MAIN
NHAN_CB1
BTFSS PORTB,4
GOTO NHA_CB1
GOTO NHAN_CB2
NHAN_CB2
BTFSS PORTB,5
GOTO NHA_CB2
GOTO NHAN_CB1
NHA_CB1
BTFSC PORTB,4
GOTO MO_CUAVAO
GOTO NHA_CB1
NHA_CB2
BTFSC PORTB,5
GOTO MO_CUARA
GOTO NHA_CB2
MO_CUAVAO
BSF PORTB,0
BCF PORTB,1
CALL DELAY2S
BCF PORTB,0
BSF PORTB,1
CALL DELAY2S
BCF PORTB,0
BCF PORTB,1
GOTO TANG
;-----MO DONG CUA RA-------/
MO_CUARA
BSF PORTB,2
BCF PORTB,3
CALL DELAY2S
BCF PORTB,2
BSF PORTB,3
CALL DELAY2S
BCF PORTB,2
BCF PORTB,3
GOTO GIAM
;===================================================
;-------HIEN THI SO XE HIEN CO TRONG BAI------------
;===================================================
;-------TANG LEN 1 DON VI NEU CO XE VAO-------------/
TANG
BSF PORTB,6
INCF DEM,1
CALL DICH_MA
MOVF KQ,W
MOVWF PORTD
GOTO MAIN
;--------GIAM XUONG 1 DON VI NEU CO XE RA------------/
GIAM
BSF PORTB,6
MOVLW D'0'
XORWF DEM,0
BTFSC STATUS,2
GOTO EMPTY
DECF DEM,1
CALL DICH_MA
MOVF KQ,W
MOVWF PORTD
GOTO MAIN
;===================================================
;-----DICH MA NHI PHAN 8 BIT SANG MA BCD------------
;===================================================
DICH_MA
MOVF DEM,W
MOVWF KQ
MOVLW D'90'
SUBWF KQ,0
BTFSC STATUS,0
GOTO ADD54
MOVLW D'80'
SUBWF KQ,0
BTFSC STATUS,0
GOTO ADD48
MOVLW D'70'
SUBWF KQ,0
BTFSC STATUS,0
GOTO ADD42
MOVLW D'60'
SUBWF KQ,0
BTFSC STATUS,0
GOTO ADD36
MOVLW D'50'
SUBWF KQ,0
BTFSC STATUS,0
GOTO ADD30
MOVLW D'40'
SUBWF KQ,0
BTFSC STATUS,0
GOTO ADD24
MOVLW D'30'
SUBWF KQ,0
BTFSC STATUS,0
GOTO ADD18
MOVLW D'20'
SUBWF KQ,0
BTFSC STATUS,0
GOTO ADD12
MOVLW D'10'
SUBWF KQ,0
BTFSC STATUS,0
GOTO ADD6
RETURN
;------------CONG THEM VAO-------------------/
ADD54
MOVLW D'54'
ADDWF KQ,1
RETURN
ADD48
MOVLW D'48'
ADDWF KQ,1
RETURN
ADD42
MOVLW D'42'
ADDWF KQ,1
RETURN
ADD36
MOVLW D'36'
ADDWF KQ,1
RETURN
ADD30
MOVLW D'30'
ADDWF KQ,1
RETURN
ADD24
MOVLW D'24'
ADDWF KQ,1
RETURN
ADD18
MOVLW D'18'
ADDWF KQ,1
RETURN
ADD12
MOVLW D'12'
ADDWF KQ,1
RETURN
ADD6
MOVLW D'6'
ADDWF KQ,1
RETURN
;================================================
;--------BAO TRANG THAI CUA BAI GIU XE-----------
;----------------EMPTY-------------------
;================================================
EMPTY
BCF PORTB,6
GOTO NHAN_CB1
;===================DELAY=======================
DELAY2S
BSF STATUS,5
BCF STATUS,6
BCF OPTION_REG,3
BSF OPTION_REG,2
BCF OPTION_REG,1
BCF OPTION_REG,0
BCF STATUS,5
MOVLW D'250'
MOVWF TAM; TAM=250/
BATDAU
MOVLW D'5'
MOVWF TMR0
BSF STATUS,5
BCF OPTION_REG,5
BCF STATUS,5
LOOP1
BTFSS INTCON,2
GOTO LOOP1
BCF INTCON,2
DECFSZ TAM,1
GOTO BATDAU
RETURN
END
có ai cho em xin cái lưu đồ với cái mạch lý thuyết không.đang làm đồ án phần này
Trả lờiXóacó ai cho em xin cái lưu đồ với cái mạch lý thuyết không.đang làm đồ án phần này
Trả lờiXóađỵt mẹ.... mấy thằng lồn..ngu thế ko biết..nhìn vào mà vẽ ra sơ đồ
Trả lờiXóa