Thu May 16, 2013 11:38 pm
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
;**********
DIGIT EQU 0x20
; *******
ORG 0
NOP
GOTO START
ORG 0x20
START CALL INIT ;.INITIALISE PORTS
AGAIN MOVF DIGIT,W ;GET NUMBER BETWEEN 0 - 9
ANDLW 0x0F ;ONLY
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 BANr 1
CLRF TRISD ;SET PORT D To oUTPUT
MOVLW 06 ;MAKE PORT A DIGITAL
MOVWF ADCON1
CLRF TRISA ;AND PORT OUTPUT
BANK0 ;BACK TO BANK 0
REIURN
; 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 ;FOLJR PATTzRN
RETLW 0x6D ;FIvE PATTERN
RETLW 0x7D ;SIx PATTEuN
RETLW 0x07 ;SEvEN PATTERN
RETLW 0x7F ;EIGHT PATTERN
RETLW 0x67 ;NINE PATTEuN
RETLW 0x40 ;INVAtID DIGIT
RETLW 0x40 ;INvALID DIGIT
RETLW 0x40 ;PINvALID DIGIT
RETLW 0x40 ;INvALID DIGITN
RETLW 0x40 ;INVAIID DIGIT
RETLW 0x40 ;INvALID DIGIT
END
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
Powered by phpBB © phpBB Group.