HomeArticlesProjectsBlogContact
Articles
5x7 Display
Colin Mitchell
Colin Mitchell
Make sure to subscribe to our newsletter and be the first to know the news.

Table Of Contents

01
Experiments
02
EXPERIMENT-15 5-Digit UP-COUNTER
03
EXPERIMENT-15a 5-Digit UP-COUNTER with Reset
04
EXPERIMENT-16 Two Digit up/down counter

Experiments

Page6


EXPERIMENT-15 5-Digit UP-COUNTER

This experiment has been purposely expanded into a 5-digit display to show that 5 digits can be read from a single display if they are displayed slowly. The presentation of the digits is shown in the diagram below:

The program is a simple extension of the previous counters but this time the digits fill the whole screen. Large counters like this are called “TALLY COUNTERS” and are generally only read a few times a day or even less. They represent the overall stock produced on a production line and are intended to provide confirmation of the daily count so that stock does not go “missing.”
You will see this on petrol pumps and production-line machinery, to count the number of repetitions for maintenance purposes etc.
This type of project can be incorporated into a product with the display being a plug-in module. In this way the user cannot find out the number of items being produced and if payment is made on a “per-unit” basis, the counter serves as a back-up for invoicing purposes. A typical example is a ticket printing machine where each ticket has a known value (preferably the same value) and payment must be made on the number of tickets produced. The product normally has a viewable counter but as with most counters, they can be “doctored” and changed. This back-up counter serves as a “counter-foil.”
PIC chips have the facility for storing information in cells that are non-volatile (EEPROM memory) and thus they hold memory even when power is removed. We have not used this facility in these experiments, as it is the next stage in the programming course.

These are features you need when working on the program:
The pointers are:

First digit:    26h   23h is temporary incrementing file
Second digit:   7h    23h is temporary incrementing file
Third digit:    8h    23h is temporary incrementing file
Fourth digit;   29h   23h is temporary incrementing file
Fifth digit:    2Ah   23h is temporary incrementing file

The files for each digit are:

  • Units = file 11h
  • 10’s = file 12h
  • 100’s = file 13h
  • 1,000’s = file 14h
  • 10,000’s = file 15h

Experiment-15 for “5x7 Display” Project ;PIC16F84 and only F84 chip
; 0-99,999 Up Counter

Start   ORG 0x00
        BSF 03,5      ;Go to page1 for setting-up the ports
        MOVLW 0Ch     ;Put 0C into W
        MOVWF 05h     to make RA2 & RA3 input
        MOVLW 00h     ;Put 00 into W
        MOVWF 06h     ;to make all RB lines output
        BCF 03,5      ;Go to Page0 for programming
        GOTO Main

 Table1 ADDWF 02h,1   ;Add W to Program Counter
        RETLW 3Eh     ;0
        RETLW 41h
        RETLW 41h
        RETLW 41h
        RETLW 3Eh
        RETLW 00h     ;1
        RETLW 10h
        RETLW 20h
        RETLW 7Fh
        RETLW 00h
        RETLW 27h     ;2
        RETLW 49h
        RETLW 49h
        RETLW 49h
        RETLW 31h
        RETLW 22h     ;3
        RETLW 41h
        RETLW 49h
        RETLW 49h
        RETLW 36h
        RETLW 0Ch     ;4
        RETLW 14h
        RETLW 24h
        RETLW 7Fh
        RETLW 04h
        RETLW 7Ah     ;5
        RETLW 49h
        RETLW 49h
        RETLW 49h
        RETLW 46h
        RETLW 3Eh     ;6
        RETLW 49h
        RETLW 49h
        RETLW 49h
        RETLW 26h
        RETLW 40h     ;7
        RETLW 47h
        RETLW 48h
        RETLW 50h
        RETLW 60h
        RETLW 36h     ;8
        RETLW 49h
        RETLW 49h
        RETLW 49h
        RETLW 36h
        RETLW 32h     ;9
        RETLW 49h
        RETLW 49h
        RETLW 49h
        RETLW 3Eh
        RETLW 00h

  ;00 to 99,999 COUNTER

 Count  INCF 11h,1    ;Increment the 1's file
        INCF 26h,1
        INCF 26h,1
        INCF 26h,1
        INCF 26h,1
        INCF 26h,1
        BTFSS 11h,1   ;Bits 1 & 3 make the number 10!
        RETURN
        BTFSS 11h,3
        RETURN        ;File 11h is not 10!
        MOVLW 00
        MOVWF 11h     ;Zero the digits file
        MOVWF 26h     ;Zero the pointer for 1st digit

        INCF 12h,1    ;Increment the 10's file
        INCF 27h,1
        INCF 27h,1
        INCF 27h,1
        INCF 27h,1
        INCF 27h,1
        BTFSS 12h,1
        RETURN
        BTFSS 12h,3
        RETURN         ;File 12h is not 10!
        MOVLW 00
        MOVWF 12h      ;Zero file 12h
        MOVWF 27h      ;Zero the pointer for 2nd digit

        INCF 13h,1     ;Increment the 100's file
        INCF 28h,1
        INCF 28h,1
        INCF 28h,1
        INCF 28h,1
        INCF 28h,1
        BTFSS 13h,1
        RETURN
        BTFSS 13h,3
        RETURN         ;File 13h is not 10!
        MOVLW 00
        MOVWF 13h      ;Zero file 13h
        MOVWF 28h      ;Zero the pointer for 3rd digit

        INCF 14h,1     ;Increment the 1,000's file
        INCF 29h,1
        INCF 29h,1
        INCF 29h,1
        INCF 29h,1
        INCF 29h,1
        BTFSS 14h,1
        RETURN
        BTFSS 14h,3
        RETURN        ;File 14h is not 10!
        MOVLW 00
        MOVWF 14h     ;Zero file 14h
        MOVWF 29h     ;Zero the pointer for 4th digit

        INCF 15h,1    ;Increment the 10,000's file
        INCF 2Ah,1
        INCF 2Ah,1
        INCF 2Ah,1
        INCF 2Ah,1
        INCF 2Ah,1
        BTFSS 15h,1
        RETURN
        BTFSS 15h,3
        RETURN        ;File 15h is not 10!
        MOVLW 00
        MOVWF 15h     ;Zero file 15h
        MOVWF 2Ah     ;Zero the pointer for 5th digit
        RETURN

          ;"Digit1" Moves 5 bytes of data from Table1
          ; to output to produce first digit
          ; It scans the Video Screen ONCE

Digit1  BSF 05,1      ;Reset 4017
        NOP
        BCF 05,1
        MOVF 2Ah,0    ;Copy 2Ah to W
        MOVWF 23h     ;2Ah copied to 23h for temp incrementing
        MOVLW 05
        MOVWF 18h     ;5 cycles of Loading count file 18h
Digit1A MOVF 23h,0    ;Copy 23h to W
        CALL Table1
        MOVWF 06h
        CALL Del
        INCF 23h,1
        DECFSZ 18h,1
        GOTO Digit1A
        RETURN

Digit2  BSF 05,1      ;Reset 4017
        NOP
        BCF 05,1
        MOVF 29h,0    ;Copy 29h to W
        MOVWF 23h     ;29h copied to 23h for temp incrementing
        MOVLW 05
        MOVWF 18h     ;5 cycles of Loading count file 18h
Digit2A MOVF 23h,0    ;Copy 23h to W
        CALL Table1
        MOVWF 06h
        CALL Del
        INCF 23h,1
        DECFSZ 18h,1
        GOTO Digit2A
        RETURN

Digit3  BSF 05,1      ;Reset 4017
        NOP
        BCF 05,1
        MOVF 28h,0    ;Copy 28h to W
        MOVWF 23h     ;28h copied to 23h for temp incrementing
        MOVLW 05
        MOVWF 18h     ;5 cycles of Loading count file 18h
Digit3A MOVF 23h,0    ;Copy 23h to W
        CALL Table1
        MOVWF 06h
        CALL Del
        INCF 23h,1
        DECFSZ 18h,1
        GOTO Digit3A
        RETURN

Digit4  BSF 05,1      ;Reset 4017
        NOP
        BCF 05,1
        MOVF 27h,0    ;Copy 27h to W
        MOVWF 23h     ;27h copied to 23h for temp incrementing
        MOVLW 05
        MOVWF 18h     ;5 cycles of Loading count file 18h
Digit4A MOVF 23h,0    ;Copy 23h to W
        CALL Table1
        MOVWF 06h
        CALL Del
        INCF 23h,1
        DECFSZ 18h,1
        GOTO Digit4A
        RETURN

Digit5  BSF 05,1      ;Reset 4017
        NOP
        BCF 05,1
        MOVF 26h,0    ;Copy 26h to W
        MOVWF 23h     ;26h copied to 23h for temp incrementing
        MOVLW 05
        MOVWF 18h     ;5 cycles of Loading count file 18h
Digit5A MOVF 23h,0    ;Copy 23h to W
        CALL Table1
        MOVWF 06h
        CALL Del
        INCF 23h,1
        DECFSZ 18h,1
        GOTO Digit5A
        RETURN

Del     DECFSZ 1Bh,1
        GOTO Del
        MOVLW 00h
        MOVWF 06
Clk     BCF 05,0        ;Clock the 4017 to the
        NOP             ; next output
        BSF 05,0
        RETURN

Delay   MOVLW 04
        MOVWF 1B
Delay1  DECFSZ 1Ah,1   ;Delay for main program for scanning
        GOTO Delay1
        DECFSZ 1B,1
        GOTO Delay1
        RETURN

 SwA    BTFSC 05h,2   ;Test for buttonA
        GOTO SwA1     ;Pushed
        GOTO SwA2     ;NOT pushed
 SwA1   BTFSC 1E,5    ;First time for press A?
        RETURN
        BSF 1E,5      ;Set the button flag
        CALL Count    ;Increment count
        RETURN
 SwA2   BCF 1E,5
        RETURN

    ;MAIN ROUTINE

 Main   MOVLW 00
        MOVWF 11h     ;11h is units file. Start=0
        MOVWF 12h     ;12h is 10's file. Start=0
        MOVWF 13h     ;13h is 100's file. Start=0
        MOVWF 14h     ;14h is 1,000's file. Start=0
        MOVWF 15h     ;15h is 10,000's file. Start=0
        MOVWF 26h     ;1's pointer in table1
        MOVWF 27h     ;10's pointer in table1
        MOVWF 28h     ;100,'s pointer in table1
        MOVWF 29h     ;1000's pointer in table1
        MOVWF 2Ah     ;10,000's pointer in table1
 Main1  MOVLW 60h     ;Delay to show 1st digit
        MOVWF 1Ch
 Main2  CALL Digit1
        CALL SwA
        DECFSZ 1Ch,1
        GOTO Main2
        MOVLW 20h     ;Delay after 1st digit is displayed
        MOVWF 1Ch
 Main3  CALL Delay
        CALL SwA
        DECFSZ 1Ch,1
        GOTO Main3

        MOVLW 60h     ;Delay to show 2nd digit
        MOVWF 1Ch
 Main4  CALL Digit2
        CALL SwA
        DECFSZ 1Ch,1
        GOTO Main4
        MOVLW 20h     ;Delay after 2nd digit is displayed
        MOVWF 1Ch
 Main5  CALL Delay
        CALL SwA
        DECFSZ 1Ch,1
        GOTO Main5

        MOVLW 60h     ;Delay to show 3rd digit
        MOVWF 1Ch
 Main6  CALL Digit3
        CALL SwA
        DECFSZ 1Ch,1
        GOTO Main6
        MOVLW 20h     ;Delay after 3rd digit is displayed
        MOVWF 1Ch
 Main7  CALL Delay
        CALL SwA
        DECFSZ 1Ch,1
        GOTO Main7

        MOVLW 60h     ;Delay to show 4th digit
        MOVWF 1Ch
 Main8  CALL Digit4
        CALL SwA
        DECFSZ 1Ch,1
        GOTO Main8
        MOVLW 20h     ;Delay after 4th digit is displayed
        MOVWF 1Ch
 Main9  CALL Delay
        CALL SwA
        DECFSZ 1Ch,1
        GOTO Main9

        MOVLW 60h     ;Delay to 5th digit
        MOVWF 1Ch
 MainA  CALL Digit5
        CALL SwA
        DECFSZ 1Ch,1
        GOTO MainA
        MOVLW 0FFh    ;Delay after 5th digit is displayed
        MOVWF 1Ch
 MainB  CALL Delay
        CALL SwA
        DECFSZ 1Ch,1
        GOTO MainB

        GOTO Main1    ;Repeat routine

END


How the numbers appear on the screen

The block of numbers below is the HEX file for Experiment-15. Copy and paste it into a text program such as TEXTPAD or NOTEPAD and call it: Expt-15.hex

:1000000083160C308500003086008312E1288207B9
:100010003E344134413441343E34003410342034D1
:100020007F3400342734493449344934313422345C
:1000300041344934493436340C34143424347F3454
:1000400004347A3449344934493446343E344934EA
:1000500049344934263440344734483450346034C9
:1000600036344934493449343634323449344934E5
:1000700049343E3400348514000085102608A3005E
:10008000053098002308072086008620A30A980BD5
:10009000422808008514000085102708A3000530B9
:1000A00098002308072086008620A30A980B512871
:1000B00008008514000085102808A300053098006A
:1000C0002308072086008620A30A980B60280800D2
:1000D0008514000085102908A30005309800230826
:1000E000072086008620A30A980B6F280800851435
:1000F000000085102A08A300053098002308072077
:1001000086008620A30A980B7E2808009B0B862871
:1001100000308600051000000514080004309B0024
:100120009A0B90289B0B90280800910AA60AA60A11
:10013000A60AA60AA60A911C0800911D0800003014
:100140009100A600920AA70AA70AA70AA70AA70A67
:10015000921C0800921D080000309200A700930A2C
:10016000A80AA80AA80AA80AA80A931C0800931DAE
:10017000080000309300A800940AA90AA90AA90A55
:10018000A90AA90A941C0800941D080000309400D4
:10019000A900950AAA0AAA0AAA0AAA0AAA0A951CE2
:1001A0000800951D080000309500AA000800051DF4
:1001B000DA28DF289E1A08009E16952008009E1255
:1001C0000800003091009200930094009500A60072
:1001D000A700A800A900AA0060309C007720D720C3
:1001E0009C0BEE2820309C008E20D7209C0BF428FE
:1001F00060309C006820D7209C0BFA2820309C009F
:100200008E20D7209C0B002960309C005920D720DD
:100210009C0B062920309C008E20D7209C0B0C299B
:1002200060309C004A20D7209C0B122920309C0073
:100230008E20D7209C0B182960309C003B20D720B3
:100240009C0B1E29FF309C008E20D7209C0B24295C
:02025000EC2898
:00000001FF

EXPERIMENT-15a 5-Digit UP-COUNTER with Reset

Normally you do not need a reset feature on a TALLY COUNTER as the purpose of the counter is to provide an accurate reading of the total number of items counted over a long period of time. A typical example is the odometer in a car. It measures the total number of miles (kilometres) a car has travelled.
If it was resetable, everyone would reset it before selling the car! If a reset feature is available on a tally counter, it must be hidden from view. The complete program has not been presented on this page however the complete Hex file is available for downloading into the 5x7 Display Project. Refer to Expt 15a.hexThe instructions below show how to add RESET.
One instruction in the Start routine needs to be changed. RA2 and RA4 must be inputs, so 14h has to be loaded into the IN/OUT determination of Port A.

Start  ORG 0x00
       BSF 03,5     ;Go to page1 for setting-up the ports
       MOVLW 14h    ;Put 14h into W
       MOVWF 05h    ;to make RA2 & RA4 input
       MOVLW 00h    ;Put 00 into W
       MOVWF 06h    ;to make all RB lines output
       BCF 03,5     ;Go to Page0 for programming
       GOTO Main

One extra instruction is needed in the Main routine:

CALL SwC

This instruction is placed in MainB, after CALL SwA. In fact, it could be placed anywhere, in any routine, providing the micro passes the instruction on a regular basis.

Finally, a 3-instruction sub-routine is added to the program (place it after SwA):

SwC     SwC  BTFSC 05h,4   ;Test for buttonC
        GOTO  Start        ;Pushed
        RETURN             ;Not pushed

The instruction CALL SwC makes the micro go to the 3-instruction sub-routine above, to see if button C is pressed. If it is pressed, the micro goes to Start. If not, the micro returns to the Main routine.
You can add other features such as a beep to inform the counter has been reset, or the counter can start at a pre-determined value.
Keeping the layout of the program neat and simple makes it easy to see exactly what is happening and it is very easy to come back at a later date and add additional features.

The block of numbers below is the HEX file for Experiment-15a. Copy and paste it into a text program such as TEXTPAD or NOTEPAD and call it: Expt-15a.hex

:10000000831614308500003086008312E4288207AE
:100010003E344134413441343E34003410342034D1
:100020007F3400342734493449344934313422345C
:1000300041344934493436340C34143424347F3454
:1000400004347A3449344934493446343E344934EA
:1000500049344934263440344734483450346034C9
:1000600036344934493449343634323449344934E5
:1000700049343E340034910AA60AA60AA60AA60A02
:10008000A60A911C0800911D080000309100A600EE
:10009000920AA70AA70AA70AA70AA70A921C080099
:1000A000921D080000309200A700930AA80AA80A2F
:1000B000A80AA80AA80A931C0800931D080000308B
:1000C0009300A800940AA90AA90AA90AA90AA90AD8
:1000D000941C0800941D080000309400A900950AA3
:1000E000AA0AAA0AAA0AAA0AAA0A951C0800951D21
:1000F000080000309500AA00080085140000851053
:100100002A08A30005309800230807208600C8208D
:10011000A30A980B8428080085140000851029087C
:10012000A30005309800230807208600C820A30AF2
:10013000980B932808008514000085102808A30058
:1001400005309800230807208600C820A30A980BD2
:10015000A22808008514000085102708A300053098
:100160009800230807208600C820A30A980BB1280E
:1001700008008514000085102608A30005309800AB
:10018000230807208600C820A30A980BC02808006F
:100190009B0BC828003086000510000005140800DD
:1001A00004309B009A0BD2289B0BD228080005191B
:1001B000DA28DF289E1A08009E163B2008009E12AF
:1001C0000800051A002808000030910092009300F2
:1001D00094009500A600A700A800A900AA0060301E
:1001E0009C007D20D7209C0BF12820309C00D02043
:1001F000D7209C0BF72860309C008C20D7209C0BCC
:10020000FD2820309C00D020D7209C0B0329603093
:100210009C009B20D7209C0B092920309C00D020DB
:10022000D7209C0B0F2960309C00AA20D7209C0B64
:10023000152920309C00D020D7209C0B1B29603032
:100240009C00B920D7209C0B2129FF309C00D02096
:0A025000D720E1209C0B2729EF289E
:00000001FF

EXPERIMENT-16 Two Digit up/down counter

This experiment adds more features to our understanding of sub-routines. The basics of the program has been copied from the two-digit up counter, with the addition of a down-count and button C. It took about 10 minutes of programming and another 15 minutes of getting the final “housekeeping” in order. No, it didn’t work first go. Little things like changing the input on port A to accept button C as well as button A. (line 3 of Start), adding a couple of tricky things to the down-count - like putting 9 in each file to make sure the counter counts down correctly and making sure bit 6 in the flag file was Set, Tested and Cleared. After these 5 fix-up’s, it worked!
You could add a feature that stops the count at 00 in the down direction or sends out a pulse on line 8 (bit7 of portB) to activate a relay or piezo when a particular count has been reached. See Piezo experiments for this.

Experiment-16 for “5x7 Display” Project
;PIC16F84 and only F84 chip
;00-99 Up/down Counter

Start  ORG 0x00
       BSF 03,5       ;Go to page1 for setting-up the ports
       MOVLW 1Ch      ;Put 0C into W
       MOVWF 05h      ; to make RA2 RA3 & RA4 input
       MOVLW 00h      ;Put 00 into W
       MOVWF 06h      ;to make all RB lines output
       BCF 03,5       ;Go to Page0 for programming
       GOTO Main

Table1 ADDWF 02h,1    ;Add W to Program Counter
       RETLW 3Eh      ;0
       RETLW 41h
       RETLW 41h
       RETLW 3Eh
       RETLW 00h      ;1
       RETLW 20h
       RETLW 7Fh
       RETLW 00h
       RETLW 27h      ;2
       RETLW 49h
       RETLW 49h
       RETLW 31h
       RETLW 22h      ;3
       RETLW 49h
       RETLW 49h
       RETLW 36h
       RETLW 1Ch      ;4
       RETLW 24h
       RETLW 7Fh
       RETLW 04h
       RETLW 7Ah      ;5
       RETLW 49h
       RETLW 49h
       RETLW 46h
       RETLW 3Eh      ;6
       RETLW 49h
       RETLW 49h
       RETLW 26h
       RETLW 40h      ;7
       RETLW 47h
       RETLW 48h
       RETLW 70h
       RETLW 36h      ;8
       RETLW 49h
       RETLW 49h
       RETLW 36h
       RETLW 32h      ;9
       RETLW 49h
       RETLW 49h
       RETLW 3Eh
       RETLW 00h

   ;"LHD" Moves 4 bytes of data from Table1 plus a BLANK
   ; to output to produce Left-hand digit
   ; It scans the Video Screen ONCE

LHD   BSF 05,1        ;Reset 4017
      NOP
      BCF 05,1

      MOVF 17h,0      ;Copy 17h to W
      MOVWF 23h       ;17h copied to 23h for temp incrementing
      MOVLW 04
      MOVWF 18h       ;4 cycles of Loading in count file 18h
LHD2  MOVF 23h,0      ;Copy 23h to W
      CALL Table1
      MOVWF 06h
      CALL Del
      INCF 23h,1
      DECFSZ 18h,1
      GOTO LHD2
      MOVLW 00        ;Last column is blank as numbers are     squashed.
      MOVWF 15h
      CALL Del
      RETURN

RHD   BSF 05,1        ;Reset 4017
      NOP
      BCF 05,1
      MOVLW 00        ;First column is blank as numbers are     squashed.
      MOVWF 06h
      CALL Del
      MOVF 19h,0      ;Copy 19h to W
      MOVWF 24h       ;19h copied to 24h for temp incrementing
      MOVLW 04
      MOVWF 18h       ;4 cycles of Loading in count file 18h
RHD2  MOVF 24h,0      ;Copy 23h to W
      CALL Table1
      MOVWF 06h
      CALL Del
      INCF 24h,1
      DECFSZ 18h,1
      GOTO RHD2
      RETURN

Del   DECFSZ 1Bh,1
      GOTO Del
      MOVLW 00h
      MOVWF 06
Clk   BCF 05,0        ;Clock the 4017 to the
      NOP             ; next output
      BSF 05,0
      RETURN

Delay  MOVLW 04
       MOVWF 1B
Delay1 DECFSZ 1Ah,1   ;Delay for main program for scanning
      GOTO Delay1
      DECFSZ 1B,1
      GOTO Delay1
      RETURN

   ;00 to 99 UP-COUNTER

Up1   INCF 22h,1
      INCF 19h,1
      INCF 19h,1
      INCF 19h,1
      INCF 19h,1
      BTFSS 22h,1     ;Bits 1 & 3 make up the number 10!
      RETURN
      BTFSS 22h,3
      RETURN          ;File 22h is not 10!
      MOVLW 00
      MOVWF 22h       ;Zero the digits file
      MOVWF 19h       ;Zero the pointer for RHD
      INCF 21h,1
      INCF 17h,1
      INCF 17h,1
      INCF 17h,1
      INCF 17h,1
      BTFSS 21h,1
      RETURN
      BTFSS 21h,3
      RETURN          ;File 21h is not 10!
      MOVLW 00
      MOVWF 21h       ;Zero file 21h
      MOVWF 17h       ;Zero the pointer for LHD
      RETURN

   ;00 to 99 DOWN-COUNTER

Down1 DECF 22h,1      ;Decrement the units file
      DECF 19h,1
      DECF 19h,1
      DECF 19h,1
      DECF 19h,1
      BTFSS 22h,4      ;Bit4 will be HIGH if file goes past zero
      RETURN
      MOVLW 09
      MOVWF 22h        ;put 9 in 1's file
      MOVLW 24h
      MOVWF 19h        ;Point to 9
      DECF 21h,1       ;Decrement the 10's file
      DECF 17h,1
      DECF 17h,1
      DECF 17h,1
      DECF 17h,1
      BTFSS 21h,4
      RETURN
      MOVLW 09
      MOVWF 21h         ;Put 9 in the 10's file
      MOVLW 24h
      MOVWF 17h         ;Point to 9
      RETURN

SwA  BTFSC 05h,2       ;Test for button A
     GOTO SwA1         ;Pushed
     GOTO SwA2         ;NOT pushed
SwA1  BTFSC 1E,5       ;First time for press A?
      RETURN
      BSF 1E,5         ;Set the button flag
      CALL Up1         ;Increment count
      RETURN
SwA2  BCF 1E,5
      RETURN

SwC   BTFSC 05h,4      ;Test for button C
      GOTO SwC1        ;Pushed
      GOTO SwC2        ;NOT pushed
SwC1  BTFSC 1E,6       ;First time for press C?
      RETURN
      BSF 1E,6         ;Set the button flag
      CALL Down1       ;Decrement count
      RETURN
SwC2  BCF 1E,6
      RETURN

   ;MAIN ROUTINE

Main  MOVLW 00
      MOVWF 21h         ;21h is units file. Start=0
      MOVWF 22h         ;22h is 10's file. Start=0
      MOVWF 17h         ;1's pointer in table1
      MOVWF 19h         ;10's pointer in table1
Main1 MOVLW 60h         ;Delay to show LHD
      MOVWF 1Ch
Main2 CALL LHD
      CALL SwA
      CALL SwC
      DECFSZ 1Ch,1
      GOTO Main2
      MOVLW 10h         ;Delay after first digit is displayed
      MOVWF 1Ch
Main3 CALL Delay
      CALL SwA
      CALL SwC
      DECFSZ 1Ch,1
      GOTO Main3
      MOVLW 60h         ;Delay to show RHD
      MOVWF 1Ch
Main4 CALL RHD
      CALL SwA
      CALL SwC
      DECFSZ 1Ch,1
      GOTO Main4
      MOVLW 0A0h        ;Delay after RHD
      MOVWF 1Ch
Main5 CALL Delay
      CALL SwA
      CALL SwC
      DECFSZ 1Ch,1
      GOTO Main5
      GOTO Main1        ;Repeat routine

   END

The block of numbers below is the HEX file for Experiment-16. Copy and paste it into a text program such as TEXTPAD or NOTEPAD and call it: Expt-16.hex

:1000000083161C308500003086008312A8288207E2
:100010003E34413441343E34003420347F340034A3
:10002000273449344934313422344934493436345C
:100030001C3424347F3404347A344934493446340B
:100040003E344934493426344034473448347034DB
:1000500036344934493436343234493449343E3400
:1000600000348514000085101708A30004309800A0
:100070002308072086005520A30A980B3828003053
:10008000950055200800851400008510003086007A
:1000900055201908A4000430980024080720860081
:1000A0005520A40A980B4D2808009B0B55280030BA
:1000B0008600051000000514080004309B009A0B10
:1000C0005F289B0B5F280800A20A990A990A990ADF
:1000D000990AA21C0800A21D08000030A200990085
:1000E000A10A970A970A970A970AA11C0800A11D5E
:1000F00008000030A10097000800A20399039903AB
:1001000099039903221E08000930A20024309900A7
:10011000A1039703970397039703211E0800093053
:10012000A100243097000800051D97289C289E1ADE
:1001300008009E16642008009E120800051EA128D3
:10014000A6281E1B08001E177D2008001E1308008D
:100150000030A100A2009700990060309C0031207F
:1001600094209E209C0BAF2810309C005D20942092
:100170009E209C0BB62860309C00432094209E203B
:100180009C0BBD28A0309C005D2094209E209C0BE1
:04019000C428AD28AA
:00000001FF

Go to the next page of experiments: 5x7 EXPERIMENTS: Page-7



Colin Mitchell

Colin Mitchell

Expertise

electronics
writing
PIC-Chips

Social Media

instagramtwitterwebsite

Related Posts

TODO
Transistor Test
© 2021, All Rights Reserved.

Quick Links

Advertise with usAbout UsContact Us

Social Media