Pic16f877 七段數碼管顯示電路

admin @ 2014-03-14 , reply:0

概述
電路圖程序范例:1。七段數碼管顯示器顯示1234循環2。七段顯示器顯示0000〜9999(自動加1)循環七段顯示器顯示1234循環:范例一:7seg1.*  ……



電路圖
程序范例:
1。七段數碼管顯示器顯示1234循環
2。七段顯示器顯示0000〜9999(自動加1)循環
七段顯示器顯示1234循環:
范例一:7seg1.*
 
 
 
LIST
P=16F877,R=DEC
;
 
#INCLUDE
MOVF
DB1,0
CBLOCK
H'20'
CALL
TABLE
DB0,DB1
 
MOVWF
PORTSEG
ENDC
 
MOVLW
H'FB'
;
 
MOVWF
PORTCA
PORTSEG EQU
PORTD
CALL
DELAY25
TRISEG EQU
TRISD
BSF
PORTCA,2
PORTCA EQU
PORTB
;
 
TRICA EQU
TRISB
SWAPF
DB1,0
;
 
CALL
TABLE
ORG
0
MOVWF
PORTSEG
NOP
 
MOVLW
H'F7'
BANKSEL
TRICA
MOVWF
PORTCA
MOVLW
0
CALL
DELAY25
MOVWF
TRICA
BSF
PORTCA,3
MOVWF
TRISEG
GOTO
MAIN
BANKSEL
PORTCA
;
 
MOVLW
0XFF
TABLE: ANDLW
H'0F'
MOVWF
PORTCA
ADDWF
PCL
 
MOVLW
H'12'
T1:
RETLW
H'C0'
;’0’
 
MOVWF
DB1
 
RETLW
H'F9'
;’1’
 
MOVLW
H'34'
 
RETLW
H'A4'
;’2’
 
MOVWF
DB0
 
RETLW
H'B0'
;’3’
MAIN:
MOVF
DB0,0
 
RETLW
H'99'
;’4’
 
CALL
TABLE
 
RETLW
H'92'
;’5’
 
MOVWF
PORTSEG
 
RETLW
H'82'
;’6’
 
MOVLW
H'FE'
 
RETLW
H'F8'
;’7’
 
MOVWF
PORTCA
 
RETLW
H'80'
;’8’
 
CALL
DELAY25
 
RETLW
H'90'
;’9’
 
BSF
PORTCA,0
 
RETLW
H'88'
;’A’
;
 
 
 
RETLW
H'83'
;’B’
 
SWAPF
DB0,0
 
RETLW
H'C6'
;’C’
 
CALL
TABLE
 
RETLW
H'A1'
;’D’
 
MOVWF
PORTSEG
 
RETLW
H'86'
;’E’
 
MOVLW
H'FD'
 
RETLW
H'8E'
;’F’
 
MOVWF
PORTCA
;
CALL
DELAY25
#INCLUDE
BSF
PORTCA,1
END
范例二:7seg11.*
LIST P=16F877,R=DEC
#INCLUDE
CBLOCK H'20'
ENDC
;
PORTSEG EQU PORTD
TRISEG EQU TRISD
PORTCA EQU PORTB
TRICA EQU TRISB
;
ORG 0
NOP
BANKSEL TRICA
MOVLW 0
MOVWF TRICA
MOVWF TRISEG
BANKSEL PORTCA
MOVLW 0XFF
MOVWF PORTCA
MAIN: MOVLW H'99'
MOVWF PORTSEG
MOVLW H'FE'
MOVWF PORTCA
CALL DELAY25
BSF PORTCA,0
;
MOVLW H'B0'
MOVWF PORTSEG
MOVLW H'FD'
MOVWF PORTCA
CALL DELAY25
BSF PORTCA,1
;
MOVLW H'A4'
MOVWF PORTSEG
MOVLW H'FB'
MOVWF PORTCA
CALL DELAY25
BSF PORTCA,2
;
MOVLW H'F9
MOVWF PORTSEG
MOVLW H'F7'
MOVWF PORTCA
CALL DELAY25
BSF PORTCA,3
GOTO MAIN
;
#INCLUDE
END
七段顯示器顯示0000〜9999(自動加1)循環
范例一:7seg2.*
LIST P=16F877,R=DEC
#INCLUDE
CBLOCK H'20'
R0,DB0,DB1
ENDC
;
PORTSEG EQU PORTD
TRISEG EQU TRISD
PORTCA EQU PORTB
TRICA EQU TRISB
;
ORG 0
NOP
BANKSEL TRICA
MOVLW 0
MOVWF TRICA
MOVWF TRISEG
BANKSEL PORTCA
MOVLW 0XFF
MOVWF PORTCA
ST: MOVLW 10
MOVWF R0
MOVLW 0
MOVWF DB0
MOVWF DB1
MAIN: MOVF DB0,0
CALL TABLE
MOVWF PORTSEG
MOVLW H'FE'
MOVWF PORTCA
CALL DELAY25
BSF PORTCA,0
;
SWAPF DB0,0
CALL TABLE
MOVWF PORTSEG
MOVLW H'FD'
MOVWF PORTCA
CALL DELAY25
MOVF DB1,0
ADDLW H'6'
BTFSS STATUS,1
GOTO MAIN
BCF STATUS,1



[admin via 研發互助社區 ] Pic16f877 七段數碼管顯示電路已經有2165次圍觀

http://cocdig.com/docs/show-post-794.html