Total members 11894 |It is currently Fri Nov 22, 2024 9:14 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





MULTIPLEXING SEVEN SEGMENT DECODER In order to display multi-digit number.
Code:

TITLE 
"MULTIPLEXING 7 SEGMENT DECODER"
list p = 16f877
include 
<p16f877.inc>

BANK0 macro
bcf STATUS
,RP0
bcf STATUS
,RP1
endm
BANK1 macro
bsf STATUS
,RP0
bcf STATUS
,RP1
endm

BANK2 
macro
bcf STATUS
,RP0
bsf STATUS
,RP1
endm
BANK3 macro
bsf STATUS
,RP0
bsf STATUS
,RP1
endm
;  **** EQUATES
DIGIT1 EQU 0x20
DIGIT2 EQU 0x21
DIGIT3 EQU 0x22
DIGIT4 EQU 0x23
COUNT EQU 0x24
DIGIT EQU 0x25
TEMP EQU 0x26
DELAY_TIME EQU 0x27
DATAVALUE EQU 0
; INDIRECT ADDRESS
; ******
  ORG 0
  NOP 
  GOTO START

; MAIN ROUTINE
ORG 0x20
START CALL SET_DATA  
CALL INIT 
;INITIALISE PORTS
AGAIN MOVLW 4 
;SET CoUNT = 4
MOVWF COUNT
MOVLW 0x20 
;SET PoINTER To DATA
MOVWF FSR 
;AND STORE
MOVLW 8 
;SET DIGIT To MSB
MOVWF DIGIT 
;AND STORE

NEXT_DIGIT
MOVF DATAVALUE
,;GET DIGIT
CALL GET_PATTERN 
;DECODE
MOVWF PORTD 
;AND OUTPUT
MOVF DIGIT
,;GET DIGIT TO SWITCH ON
MOVWF PORTA 
;AND SWITCH ON
CALL DELAY 
;WAIT
CLRF PORTA 
;CLEAR DISPLAy
INCF FSR 
;POINT TO NEXT DIGIT
RRF DIGIT 
;MOvE ENABLE TO NEXT DIGIT
DECF COUNT 
;COUNT COUNT - 1
BTFSS STATUS
,;IF LAST START AGAIN
GOTO NEXT_DIGIT 
;ELSE Do NExT
GOTO AGAIN 
;AND REPEAT

MOVF DIGIT
,;GET NUMBER BETWEEN 0 - 9
ANDLW 0x0F 
;ONLY 4 LSBs
CALL GET_PATTERN 
;DECODE
MOVWF PORTD 
;OUTPUT
MOVLW 01 
;SELECT 1ST DIGIT
MOVWF PORTA 
;AND oUTPUT
GOTO AGAIN 
;REPEAT FOR EVER

; PORT INITIALISATION
INIT BANK1 
;SET TO BANK 1
CLRF TRISD 
;SET PORT D To oUTPUT
MOVLW 06 
;MME PORT A DIGITAL
MOVWF ADCON1
CLRF TRISA 
;AND PORT OUTPUT
BANK0 
;BAOK TO BANK 0
RETURN

;
DECODE ROUTINE
GET_PATTERN
ADDWF PCL 
;GOTO EQUIV PATTERN
RETLW 0x3F 
;ZERo PATTERN
RETLW 0x06 
;oNE PATTERN
RETLW 0x5B 
;TWo PATTERN
RETLW 0x4F 
;THREE PATTERN
RETLW 0x66 
;FOUR PATTERN
RETLW 0x6D 
;FIvE PATTERN
RETLW 0x7D 
;SIx PATTERN
RETLW 0x07 
;SEvEN PATTERN
RETLW 0x7F 
;EIGHT PATTERN
RETLW 0x67 
;NINE PATTERN
RETLW 0x40 
;INVALID DIGIT
RETLW 0x40 
;INvALID DIGIT
RETLW 0x40 
;PINvALID DIGIT
RETLW 0x40 
;INVALID DI3ITN
RETLW 0x40 
;INVALID DIGIT
RETLW 0x40 
;INvALID DIGIT
; SE TEST DATA
SET_DATA
MOVLW 0 
;-ZERoI
MOVWF DIGIT1 
;AND STORE
MOVLW 1 
;1
MOVWF DIGIT2 
;AND SToRE
MOVLW 2 
;2
MOVWF DIGIT3 
;AND SToRE
MOVLW 3 
;3
MOVWF DIGIT4 
;AND SToRE
RETURN

;
 DELAY ROUTIN
DELAY MOVWF TEMP 
; SAVE
      MOVLW 0xFF
; SET DELAY TIME
      MOVWF DELAY_TIME
      
WAIT INCFSZ DELAY_TIME 
; COUNT DOWN
     GOTO WAIT
     MOVF TEMP
,; RESTORE W
     RETURN 
     
END




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : MULTIPLEXING Seven SEGMENT DECODER Assembly
 SEVEN SEGMENT DISPLAY     -  
 PIC Assembly For Loop Example     -  
 multiply two numbers in PIC assembly     -  
 macro usage PIC assembly     -  
 TEMPERATURE AND HEAT CONTROL Assembly     -  
 playfair cipher assembly code     -  
 Elements of Assembly Language Instruction     -  
 Control Directives usage PIC assembly     -  
 Object File Directives Usage PIC Assembly     -  
 Motor DC Speed Control by switching ON and OFF Assembly     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com