Talking Electronics PIC Theory
                                      5x7 VIDEO SCREEN

 

ROUTINES Page1

REMINDER:     These are the items you need for these experiments:
-  the 5x7 Video Screen Project (fully built),
- a 6v battery,
- programming disc "5x7 VIDEO SCREEN PROGRAMMING-1"
- an interface cable "5x7 PIC cable-1"
-  a computer.

  The first 6 experiments are on:  "Experiments Page1." (Turning a LED on, Flashing a LED, Scanning Up, Scanning up/down, Switch Debounce, Reaction Game - Hit the middle LED)
  Experiments 7, 8, 9 are on:  "Experiments Page2." (shifting columns of LEDs left/right back/forth)
  Experiments 10, 11 are on:  "Experiments Page3." (Start/Stop action via switch, Elevator display)
  Experiment 12 is on:  "Experiments Page4."  (TE Running Sign)
  Experiments 13, 14 are on:  "Experiments Page5."  (Single Digit Up Counter, Two digit Up Counter)
  Experiments 15, 16 are on:  "Experiments Page6."  (5 Digit Up Counter, Two digit Up/Down Counter)
  Experiments 17, 18, 19 are on:  "Experiments Page7."  (3 Experiments on Animation - Wipe Up etc.)
  Experiments 20, 21, 22 are on:  "Experiments Page8."  (3 more Animation including Wipe Down, Slash and Splash)
  Experiments 23, 24, 25 are on:  "Experiments Page9."  (Display after button press, Start/stop Splash, "Bull's Eye"  A Hit-the-LED game)

 



Some thoughts behind the routines in the 5x7 Video Screen project.

Some of the routines look very simple but a lot of thought has gone into their coding. One of the most important things to remember is the order in which instructions are written. Sometimes it may not matter if a file is decremented before another operation but other-times the routine will not work at all.  
If you are having trouble getting a routine to work, one solution is to remove it and set up a new experiment using just the sub-routine, start-up instructions and as few other instructions as possible. Try changing some of the variables (the literals) and gradually remove some of the instructions until something different happens. 
In the Library of Routines, the BEEP routine (in the SOUND section) is designed to produce a beep when the micro gets to a certain location in a routine. 
As a last resort, tackle the problem from a different angle by re-writing the code. In any event, don't give up. The feeling of achievement must be your driving force. 
To minimise problems like this, always write small sections of code and test it before going on. That's why we have produced a Library of Routines. They represent routines that have been tried and tested. But if you are using a different port, or already using some of the files, the code will have to be changed. These are things you must keep in mind. 

               ;nt-13 for "5x7 Video Screen" Project
                               ;PIC16F84 and only F84 chip 
                                          ; 0-9 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


     ;Ghost routine transfers data from the  Ghost files to the Video Screen
                    ; and scans the Video Screen ONCE

 Ghost    BSF 05,1 ;Reset 4017
              NOP
              BCF 05,1
              MOVF 11h,0 ;Move the data from the 
              MOVWF 06h ; Ghost files to 
              CALL DelA ; the output port
              MOVF 12h,0 ; and call a Delay so the 
              MOVWF 06h ; LED can be illuminated
              CALL DelA
              MOVF 13h,0
              MOVWF 06h
              CALL DelA
              MOVF 14h,0
              MOVWF 06h
              CALL DelA
              MOVF 15h,0
              MOVWF 06h
              CALL DelA
              RETURN

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


     ;"FillGh"   Fill moves 5 bytes of data from Table1 to
               ; to Ghost area via Indirect Addressing

 FillGh    MOVLW 05
              MOVWF 18h      ;5 cycles of Loading
              MOVLW 11h
              MOVWF 04        ;Move start of Ghost locations to FSR
 FillGh2   MOVF 17h,0      ;Move table pointer to W
               CALL Table1
               MOVWF 00        ;Move W to INDF (move into what FSR looks at)
               INCF 04h,1             ;Increment the FSR to look at next file
               INCF 17h,1
               DECFSZ 18h,1
               GOTO FillGh2
               RETURN


    ;MAIN ROUTINE

 Main      MOVLW 00
              MOVWF 17h           ;Load Table1 pointer with 00 
              CALL FillGh             ;Put "0" on Screen
 Main1    BCF 1E,5
 Main2    CALL Ghost            ;Display whatever is in Ghost files
               BTFSS 05h,2          ;Test for buttonA
               GOTO Main3           ;Pushed
               GOTO Main1           ;Not pushed

 Main3    BTFSC 1E,5
              GOTO Main2
              MOVF 17h,0             ;Has pointer reached end of table?
              XORLW 32h             ;End of Table is 32h bytes.
              BTFSS 03,2              ;Test the zero flag
              GOTO Main4
              MOVLW 00
              MOVWF 17h
Main4     CALL FillGh              ;No. Put next number on screen
              BSF 1E,5                  ;Set the button flag
              GOTO Main2


              END