Picproje Elektronik Sitesi

DERLEYİCİLER => PIC Assembly => Konuyu başlatan: ipek - 20 Haziran 2016, 01:50:41

Başlık: 16C55 den 16F870'e dönüşüm
Gönderen: ipek - 20 Haziran 2016, 01:50:41
net'te hoş bir dosya buldum,pahalı 74C922,3,5 tipi keyboard entegreleri emule ediyor,azcık uğraştım,sanki çalışacak gibi oldu fakat sonucu çıkış portuna aktaramadım,
16F87x comparator barındırmıyor,dikkate almadım
ADCON1'e 110 yükleyip tüm A Portunu digital yaptım
Ram bölgesini yeniledim,
organize adresini 0000 yaptım
kısacası anladığım kadarıyla elimden gelen değişiklikleri uyguladım.
her iki dosyanın Isis simulasyonu mevcut,
gözlemlediğim kadarı ile ASM ye sadece Z'den ve Kabil Atıcı hocamdan olumlu cevaplar gelmiş,diğer arkadaşlar ilk aklına gelen önerileri paylaşmışlar,
acelesi ve önemi yok bir yol gösterirseniz devam edeceğim,kolaylıklar dilerim

http://s2.dosya.tc/server2/0hxm1h/16C55_keyboard_controller.rar.html (http://s2.dosya.tc/server2/0hxm1h/16C55_keyboard_controller.rar.html)

http://s2.dosya.tc/server2/qqsfoo/74C925_16F870.rar.html (http://s2.dosya.tc/server2/qqsfoo/74C925_16F870.rar.html)



kusursuz çalışan artık bulunmayan 16C55'e ait dosya

LIST P=16C55 ; N=38, C=132, R=DEC

TITLE "KEYPAD ENCODER/EMULATOR - ENCODER.ASM"

;****************************************************************************
;*                               Keypad Encoder/Emulator                 *
;*                     Copyright 1996 DTE MICRO SYSTEMS                     *
;*               For use on the DTE MULTI KEYPAD EMULATOR board             *
;*              Note: This requires a PIC16C55 with RC oscillator           *
;****************************************************************************

; Define the general registers and I/O port addresses

RTCC EQU 01 ; Real Time Clock/Counter register address
PC EQU 02 ; Program Counter address
STATUS EQU 03 ; Status register address
FSR EQU 04 ; File Select Register address
PORTA EQU 05 ; I/O Port A (lower 4 bits only available)
PORTB EQU 06 ; I/O Port B (all 8 bits available)
PORTC EQU 07 ; I/O Port C (all 8 bits available)


; Assign labels to programming constants used in PIC assembly language.
; These are used by all instructions which have a choice of destination
; register for the result of their operation, where 'd' can be 1 or 0.
; Doing this makes program listings more logical and easier to read.

W EQU 0 ; Destination register becomes 'W' (acc.)
F EQU 1 ; Destination register becomes 'F' (file)

; Assign labels to the various bit values of the STATUS register (03h)

CARRY EQU 0 ; carry bit
DCARRY EQU 1 ; digit carry bit
ZERO EQU 2 ; Zero bit
PDOWN EQU 3 ; power-down bit
WATDOG EQU 4 ; watchdog time-out bit


; Assign basic pin labels to the bit numbers for I/O port A.

RA0 EQU 00 ; Port A I/O bit 0
RA1 EQU 01 ; Port A I/O bit 1
RA2 EQU 02 ; Port A I/O bit 2
RA3 EQU 03 ; Port A I/O bit 3

; Assign basic pin labels to the bit numbers for I/O port B.

RB0 EQU 00 ; Port B I/O bit 0
RB1 EQU 01 ; Port B I/O bit 1
RB2 EQU 02 ; Port B I/O bit 2
RB3 EQU 03 ; Port B I/O bit 3
RB4 EQU 04 ; Port B I/O bit 4
RB5 EQU 05 ; Port B I/O bit 5
RB6 EQU 06 ; Port B I/O bit 6
RB7 EQU 07 ; Port B I/O bit 7

; Assign basic pin labels to the bit numbers for I/O port C.

RC0 EQU 00 ; Port C I/O bit 0
RC1 EQU 01 ; Port C I/O bit 1
RC2 EQU 02 ; Port C I/O bit 2
RC3 EQU 03 ; Port C I/O bit 3
RC4 EQU 04 ; Port C I/O bit 4
RC5 EQU 05 ; Port C I/O bit 5
RC6 EQU 06 ; Port C I/O bit 6
RC7 EQU 07 ; Port C I/O bit 7

; Assign labels to the various (RAM) data file registers used

ORG 08 ; Set base address for RAM

COUNT1 RES 1 ; General purpose counter
IPBUFF RES 1 ; Input buffer status byte
LASKEY RES 1 ; Previous offset into lookup table
OFFSET RES 1 ; Current offset into lookup table
OPBUFF RES 1 ; Binary output code for RC0 to RC4
STROBE RES 1 ; Column strobe line value

; END OF EQUATES SECTION

;****************************************************************************

; Start of program memory area

ORG 0000 ; SET ORIGIN ADDRESS

;****************************************************************************

; Scan the Keypad and put the data in "IPBUFF".  If the value is the same
; as "LASKEY" then try scanning other buttons to allow 'n' key rollover.
; To protect against possible 'glitches' causing the DDRs to change states,
; the DDRs for port A and port B are constantly updated by this routine.

SCANKP
CLRF OPBUFF ; START WITH "OPBUFF" EMPTY
CLRF OFFSET ; RESET OFFSET COUNTER TO ZERO
MOVLW B'11111111'
TRIS PORTA ; SET PORT A FOR INPUT
TRIS PORTB ; INITIALLY SET PORT B FOR INPUT
MOVWF PORTB ; PRESET ALL PORT B LINES HIGH
MOVLW B'11111110'
MOVWF STROBE ; PREPARE COLUMN STROBE LINE
SCAN2
MOVF STROBE,W ; GET CURRENT STROBE VALUE IN 'W'
MOVWF PORTB ; PREPARE THE PORT LINES FIRST
TRIS PORTB ; NOW ENABLE THE OUTPUTS
NOP
NOP ; ALLOW I/O LINES TO STABILISE
NOP
MOVF PORTA,W ; GET BUTTON PRESSED COLUMN DATA
MOVWF IPBUFF ; SAVE IT IN "IPBUFF"

; Now, starting from the top row of the column we have just sampled,
; check each button in turn to see if any of them was pressed.  After
; each test, incriment the "OFFSET" value to adjust the offset into
; the lookup table of binary output codes - used later.

BTFSS IPBUFF,RA0 ; SKIP IF NOT THE TOP ROW
GOTO SCAN4 ; OTHERWISE SORT IT OUT
INCF OFFSET ; ADD 1 TO LOOKUP TABLE OFFSET
BTFSS IPBUFF,RA1 ; SKIP IF NOT THE 2nd ROW
GOTO SCAN4 ; OTHERWISE SORT IT OUT
INCF OFFSET ; ADD 1 TO LOOKUP TABLE OFFSET
BTFSS IPBUFF,RA2 ; SKIP IF NOT THE 3rd ROW
GOTO SCAN4 ; OTHERWISE SORT IT OUT
INCF OFFSET ; ADD 1 TO LOOKUP TABLE OFFSET
BTFSS IPBUFF,RA3 ; SKIP IF NOT THE BOTTOM ROW
GOTO SCAN4 ; OTHERWISE SORT IT OUT
INCF OFFSET ; ADD 1 TO LOOKUP TABLE OFFSET

; No buttons were pressed in this particular column, but we need to
; check any remaining columns that have not yet been scanned.

SCAN3
BSF STATUS,CARRY ; SET THE CARRY FLAG
RLF STROBE ; PREPARE STROBE LINE FOR NEXT COLUMN
BTFSC STATUS,CARRY ; SKIP IF ALL COLUMNS COMPLETED
GOTO SCAN2 ; ELSE GO BACK FOR THE NEXT COLUMN

; All columns have been scanned, no buttons were found to be pressed.
; In this situation the "OFFSET" location contains 20h (32 decimal)
; and cannot be converted, so exit with "LASKEY" intact from last time.

GOTO CONVERT ; EXIT WITHOUT UPDATING "LASKEY"

; A button is pressed, and "OFFSET" holds the unique offset value for it
; (after keypad prioritisation, of course, ie, lowest column/row address).
; Set the Data Available 'DA' line high, and copy the value into "LASKEY".

SCAN4
BSF OPBUFF,RC6 ; PREPARE 'DA' LINE HIGH IN "OPBUFF"
MOVF OFFSET,W ; GET CURRENT "OFFSET" VALUE
MOVWF LASKEY ; AND UPDATE "LASKEY" WITH IT

;****************************************************************************

; Convert the value in "LASKEY" into a binary code for output on port C.
; These codes can be modified to suit your own needs.  The characters on
; the right correspond to the keypad layout shown in Figure 2 of the text.

CONVERT
BCF STATUS,CARRY ; CLEAR THE CARRY FLAG
MOVF LASKEY,W ; GET OFFSET VALUE IN 'W'
ADDWF PC,F ; ADD IT TO THE PROGRAM COUNTER
RETLW H'00' ; CODE FOR 'F' BUTTON - RA0 to RB0
RETLW H'01' ; CODE FOR 'B' BUTTON - RA1 to RB0
RETLW H'02' ; CODE FOR '7' BUTTON - RA2 to RB0
RETLW H'03' ; CODE FOR '3' BUTTON - RA3 to RB0
RETLW H'04' ; CODE FOR 'E' BUTTON - RA0 to RB1
RETLW H'05' ; CODE FOR 'A' BUTTON - RA1 to RB1
RETLW H'06' ; CODE FOR '6' BUTTON - RA2 to RB1
RETLW H'07' ; CODE FOR '2' BUTTON - RA3 to RB1
RETLW H'08' ; CODE FOR 'D' BUTTON - RA0 to RB2
RETLW H'09' ; CODE FOR '9' BUTTON - RA1 to RB2
RETLW H'0A' ; CODE FOR '5' BUTTON - RA2 to RB2
RETLW H'0B' ; CODE FOR '1' BUTTON - RA3 to RB2
RETLW H'0C' ; CODE FOR 'C' BUTTON - RA0 to RB3
RETLW H'0D' ; CODE FOR '8' BUTTON - RA1 to RB3
RETLW H'0E' ; CODE FOR '4' BUTTON - RA2 to RB3
RETLW H'0F' ; CODE FOR '0' BUTTON - RA3 to RB3
RETLW H'10' ; CODE FOR 'X' BUTTON - RA0 to RB4
RETLW H'11' ; CODE FOR 'T' BUTTON - RA1 to RB4
RETLW H'12' ; CODE FOR 'P' BUTTON - RA2 to RB4
RETLW H'13' ; CODE FOR 'K' BUTTON - RA3 to RB4
RETLW H'14' ; CODE FOR 'W' BUTTON - RA0 to RB5
RETLW H'15' ; CODE FOR 'S' BUTTON - RA1 to RB5
RETLW H'16' ; CODE FOR 'N' BUTTON - RA2 to RB5
RETLW H'17' ; CODE FOR 'J' BUTTON - RA3 to RB5
RETLW H'18' ; CODE FOR 'V' BUTTON - RA0 to RB6
RETLW H'19' ; CODE FOR 'R' BUTTON - RA1 to RB6
RETLW H'1A' ; CODE FOR 'M' BUTTON - RA2 to RB6
RETLW H'1B' ; CODE FOR 'H' BUTTON - RA3 to RB6
RETLW H'1C' ; CODE FOR 'U' BUTTON - RA0 to RB7
RETLW H'1D' ; CODE FOR 'Q' BUTTON - RA1 to RB7
RETLW H'1E' ; CODE FOR 'L' BUTTON - RA2 to RB7
RETLW H'1F' ; CODE FOR 'G' BUTTON - RA3 to RB7

;****************************************************************************

; Sort out the I/O signals and binary output code required on port C.
; Location "OPBUFF" holds the binary code for keypad data, plus the 'DA'
; bit status for RC6.  Port lines RC0 to RC4 must only be set for output
; if the OE input on RC5 is low, otherwise they must be set as inputs.

OUTPUT
MOVF OPBUFF,W ; GET BINARY OUTPUT VALUE
MOVWF PORTC ; PREPARE PORT C BEFORE ENABLING IT
MOVLW B'10111111' ; INITIALLY SET JUST RC6 FOR OUTPUT
BTFSS PORTC,RC5 ; SKIP IF 'RC5' IS HIGH
MOVLW B'10100000' ; ELSE USE KEYPAD CODE TOO
TRIS PORTC ; ENABLE THE OUTPUTS

; Add a short switch debounce period to the whole process.  This
; will compensate for any worn or 'iffy' contacts on the keypad.

DBOUNC
DECFSZ COUNT1 ; WAIT ...
GOTO DBOUNC
RETLW 0 ; FINISHED - RETURN

;****************************************************************************

; Beginning of the main program (program entry point)

START
MOVLW B'00000000'
MOVWF PORTC ; PREPARE ALL PORT C LINES LOW
MOVLW B'10111111'
TRIS PORTC ; INITIALLY SET JUST RC6 FOR OUTPUT
MOVLW H'20'
CLRF COUNT1 ; CLEAR KEYPAD DEBOUNCE TIMER
CLRF LASKEY ; SET "LASKEY" TO ZERO

;****************************************************************************

COMMAND
CALL SCANKP ; SCAN THE KEYPAD MATRIX
BCF STATUS,CARRY ; CLEAR THE CARRY FLAG
ADDWF OPBUFF,F ; ADD CONVERTED CODE TO "OPBUFF"
CALL OUTPUT ; SORT OUT THE OUTPUT CODE
GOTO COMMAND ; DO IT FOREVER

;****************************************************************************

; Set up the reset vector for the type of processor used.
; This varies between devices but is at 1FFh on the 16C55

ORG H'1FF'
GOTO START
ZZZ ; END OF PROGRAM MARKER
END



buda benim kuşa çevirdiğim 16F870'e çevirdiğim dosya...
#include p16f870.inc

; Assign basic pin labels to the bit numbers for I/O port A.
__CONFIG _CP_OFF & _WDT_OFF & _BODEN_OFF & _PWRTE_ON & _XT_OSC & _LVP_OFF & _CPD_OFF
Errorlevel ,-302 ,-305

LIST P=16F870, N=38, C=132, R=DEC


; Assign labels to the various bit values of the STATUS register (03h)

CARRY EQU 0 ; carry bit


; Assign basic pin labels to the bit numbers for I/O port A.

RA0 EQU 00 ; Port A I/O bit 0
RA1 EQU 01 ; Port A I/O bit 1
RA2 EQU 02 ; Port A I/O bit 2
RA3 EQU 03 ; Port A I/O bit 3

; Assign basic pin labels to the bit numbers for I/O port B.

RB0 EQU 00 ; Port B I/O bit 0
RB1 EQU 01 ; Port B I/O bit 1
RB2 EQU 02 ; Port B I/O bit 2
RB3 EQU 03 ; Port B I/O bit 3
RB4 EQU 04 ; Port B I/O bit 4
RB5 EQU 05 ; Port B I/O bit 5
RB6 EQU 06 ; Port B I/O bit 6
RB7 EQU 07 ; Port B I/O bit 7

; Assign basic pin labels to the bit numbers for I/O port C.

RC0 EQU 00 ; Port C I/O bit 0
RC1 EQU 01 ; Port C I/O bit 1
RC2 EQU 02 ; Port C I/O bit 2
RC3 EQU 03 ; Port C I/O bit 3
RC4 EQU 04 ; Port C I/O bit 4
RC5 EQU 05 ; Port C I/O bit 5
RC6 EQU 06 ; Port C I/O bit 6
RC7 EQU 07 ; Port C I/O bit 7

; Assign labels to the various (RAM) data file registers used

;; ORG 20 ; Set base address for RAM 8
  CBLOCK 0x20 ; Set base address for RAM
COUNT1 ; General purpose counter
IPBUFF ; Input buffer status byte
LASKEY ; Previous offset into lookup table
OFFSET ; Current offset into lookup table
OPBUFF ; Binary output code for RC0 to RC4
STROBE ; Column strobe line value
ENDC

; END OF EQUATES SECTION



; Start of program memory area

ORG 0000 ; SET ORIGIN ADDRESS

;;START

; INITIALISE PORTS

BSF STATUS,5
movlw b'00001111'       ;
movwf TRISA
movlw b'00000000' ;
movwf TRISB
movlw b'10100000' ;
movwf TRISC

; MOVLW B'00000000'
; MOVWF PORTC ; PREPARE ALL PORT C LINES LOW
; MOVLW B'10111111'
; TRIS PORTC ; INITIALLY SET JUST RC6 FOR OUTPUT
; MOVLW H'20'


;---------------------------------------------------------
movlw b'00000110' ; All analog pins = digital
movwf ADCON1 ; 16F870'te comparator yok CMCON 7 de gerek yok
;----------------------------------------------------------

bcf STATUS,RP0  ; back to RAM page 0






;; MOVLW H'20'
CLRF COUNT1 ; CLEAR KEYPAD DEBOUNCE TIMER
CLRF LASKEY ; SET "LASKEY" TO ZERO


;****************************************************************************

; Start of program memory area
START


;; ORG 0000 ; SET ORIGIN ADDRESS



;****************************************************************************

COMMAND
CALL SCANKP ; SCAN THE KEYPAD MATRIX
BCF STATUS,CARRY ; CLEAR THE CARRY FLAG
ADDWF OPBUFF,F ; ADD CONVERTED CODE TO "OPBUFF"
CALL OUTPUT ; SORT OUT THE OUTPUT CODE
GOTO COMMAND ; DO IT FOREVER

;****************************************************************************

;****************************************************************************

; Scan the Keypad and put the data in "IPBUFF".  If the value is the same
; as "LASKEY" then try scanning other buttons to allow 'n' key rollover.
; To protect against possible 'glitches' causing the DDRs to change states,
; the DDRs for port A and port B are constantly updated by this routine.

SCANKP
CLRF OPBUFF ; START WITH "OPBUFF" EMPTY
CLRF OFFSET ; RESET OFFSET COUNTER TO ZERO
MOVLW B'00001111' ;11111111
;; TRIS PORTA ; SET PORT A FOR INPUT
MOVWF TRISA
;; TRIS PORTB ; INITIALLY SET PORT B FOR INPUT
MOVWF TRISB
MOVWF PORTB ; PRESET ALL PORT B LINES HIGH
MOVLW B'11111110'
MOVWF STROBE ; PREPARE COLUMN STROBE LINE
SCAN2
MOVF STROBE,W ; GET CURRENT STROBE VALUE IN 'W'
MOVWF PORTB ; PREPARE THE PORT LINES FIRST
;; TRIS PORTB ; NOW ENABLE THE OUTPUTS
MOVWF   TRISB
NOP
NOP ; ALLOW I/O LINES TO STABILISE
NOP
MOVF PORTA,W ; GET BUTTON PRESSED COLUMN DATA
MOVWF IPBUFF ; SAVE IT IN "IPBUFF"

; Now, starting from the top row of the column we have just sampled,
; check each button in turn to see if any of them was pressed.  After
; each test, incriment the "OFFSET" value to adjust the offset into
; the lookup table of binary output codes - used later.

BTFSS IPBUFF,RA0 ; SKIP IF NOT THE TOP ROW
GOTO SCAN4 ; OTHERWISE SORT IT OUT
INCF OFFSET ; ADD 1 TO LOOKUP TABLE OFFSET
BTFSS IPBUFF,RA1 ; SKIP IF NOT THE 2nd ROW
GOTO SCAN4 ; OTHERWISE SORT IT OUT
INCF OFFSET ; ADD 1 TO LOOKUP TABLE OFFSET
BTFSS IPBUFF,RA2 ; SKIP IF NOT THE 3rd ROW
GOTO SCAN4 ; OTHERWISE SORT IT OUT
INCF OFFSET ; ADD 1 TO LOOKUP TABLE OFFSET
BTFSS IPBUFF,RA3 ; SKIP IF NOT THE BOTTOM ROW
GOTO SCAN4 ; OTHERWISE SORT IT OUT
INCF OFFSET ; ADD 1 TO LOOKUP TABLE OFFSET

; No buttons were pressed in this particular column, but we need to
; check any remaining columns that have not yet been scanned.

SCAN3
BSF STATUS,CARRY ; SET THE CARRY FLAG
RLF STROBE ; PREPARE STROBE LINE FOR NEXT COLUMN
BTFSC STATUS,CARRY ; SKIP IF ALL COLUMNS COMPLETED
GOTO SCAN2 ; ELSE GO BACK FOR THE NEXT COLUMN

; All columns have been scanned, no buttons were found to be pressed.
; In this situation the "OFFSET" location contains 20h (32 decimal)
; and cannot be converted, so exit with "LASKEY" intact from last time.

GOTO CONVERT ; EXIT WITHOUT UPDATING "LASKEY"

; A button is pressed, and "OFFSET" holds the unique offset value for it
; (after keypad prioritisation, of course, ie, lowest column/row address).
; Set the Data Available 'DA' line high, and copy the value into "LASKEY".

SCAN4
BSF OPBUFF,RC6 ; PREPARE 'DA' LINE HIGH IN "OPBUFF"
MOVF OFFSET,W ; GET CURRENT "OFFSET" VALUE
MOVWF LASKEY ; AND UPDATE "LASKEY" WITH IT

;****************************************************************************

; Convert the value in "LASKEY" into a binary code for output on port C.
; These codes can be modified to suit your own needs.  The characters on
; the right correspond to the keypad layout shown in Figure 2 of the text.

CONVERT
BCF STATUS,CARRY ; CLEAR THE CARRY FLAG
MOVF LASKEY,W ; GET OFFSET VALUE IN 'W'
ADDWF PCL,F ; ADD IT TO THE PROGRAM COUNTER
RETLW H'00' ; CODE FOR 'F' BUTTON - RA0 to RB0
RETLW H'01' ; CODE FOR 'B' BUTTON - RA1 to RB0
RETLW H'02' ; CODE FOR '7' BUTTON - RA2 to RB0
RETLW H'03' ; CODE FOR '3' BUTTON - RA3 to RB0
RETLW H'04' ; CODE FOR 'E' BUTTON - RA0 to RB1
RETLW H'05' ; CODE FOR 'A' BUTTON - RA1 to RB1
RETLW H'06' ; CODE FOR '6' BUTTON - RA2 to RB1
RETLW H'07' ; CODE FOR '2' BUTTON - RA3 to RB1
RETLW H'08' ; CODE FOR 'D' BUTTON - RA0 to RB2
RETLW H'09' ; CODE FOR '9' BUTTON - RA1 to RB2
RETLW H'0A' ; CODE FOR '5' BUTTON - RA2 to RB2
RETLW H'0B' ; CODE FOR '1' BUTTON - RA3 to RB2
RETLW H'0C' ; CODE FOR 'C' BUTTON - RA0 to RB3
RETLW H'0D' ; CODE FOR '8' BUTTON - RA1 to RB3
RETLW H'0E' ; CODE FOR '4' BUTTON - RA2 to RB3
RETLW H'0F' ; CODE FOR '0' BUTTON - RA3 to RB3
RETLW H'10' ; CODE FOR 'X' BUTTON - RA0 to RB4
RETLW H'11' ; CODE FOR 'T' BUTTON - RA1 to RB4
RETLW H'12' ; CODE FOR 'P' BUTTON - RA2 to RB4
RETLW H'13' ; CODE FOR 'K' BUTTON - RA3 to RB4
RETLW H'14' ; CODE FOR 'W' BUTTON - RA0 to RB5
RETLW H'15' ; CODE FOR 'S' BUTTON - RA1 to RB5
RETLW H'16' ; CODE FOR 'N' BUTTON - RA2 to RB5
RETLW H'17' ; CODE FOR 'J' BUTTON - RA3 to RB5
RETLW H'18' ; CODE FOR 'V' BUTTON - RA0 to RB6
RETLW H'19' ; CODE FOR 'R' BUTTON - RA1 to RB6
RETLW H'1A' ; CODE FOR 'M' BUTTON - RA2 to RB6
RETLW H'1B' ; CODE FOR 'H' BUTTON - RA3 to RB6
RETLW H'1C' ; CODE FOR 'U' BUTTON - RA0 to RB7
RETLW H'1D' ; CODE FOR 'Q' BUTTON - RA1 to RB7
RETLW H'1E' ; CODE FOR 'L' BUTTON - RA2 to RB7
RETLW H'1F' ; CODE FOR 'G' BUTTON - RA3 to RB7

;****************************************************************************

; Sort out the I/O signals and binary output code required on port C.
; Location "OPBUFF" holds the binary code for keypad data, plus the 'DA'
; bit status for RC6.  Port lines RC0 to RC4 must only be set for output
; if the OE input on RC5 is low, otherwise they must be set as inputs.

OUTPUT
MOVF OPBUFF,W ; GET BINARY OUTPUT VALUE
MOVWF PORTC ; PREPARE PORT C BEFORE ENABLING IT
MOVLW B'10111111' ; INITIALLY SET JUST RC6 FOR OUTPUT
BTFSS PORTC,RC5 ; SKIP IF 'RC5' IS HIGH
MOVLW B'10100000' ; ELSE USE KEYPAD CODE TOO
;; TRIS PORTC ; ENABLE THE OUTPUTS
MOVWF TRISC ;*********************************************
; Add a short switch debounce period to the whole process.  This
; will compensate for any worn or 'iffy' contacts on the keypad.

DBOUNC
DECFSZ COUNT1 ; WAIT ...
GOTO DBOUNC
;; RETLW 0 ; FINISHED - RETURN
RETURN
;****************************************************************************

; Beginning of the main program (program entry point)






GOTO START

END