Advertisement
Leo_F

Untitled

Mar 6th, 2018
2,480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 1.32 KB | None | 0 0
  1. MAIN        CALL        EC8INIT
  2.         CALL        E88INIT
  3.         CALL        EKINIT
  4.                    
  5.        
  6. LOOP        CLRF        PORTD       ; Clear PORTD      
  7.         CALL        EC8NEXT     ; Advance to and activate next column
  8.         CALL        EKDOWNQ     ; Check if any key in column is pressed
  9.         CALL        EC8FREE     ; Turn off all columns
  10.         MOVF        IKTEMP, W   ; Move last pressed key to work
  11.         CALL        GET_NRCODE  ; Look up 7seg code in table
  12.         MOVWF       PORTD       ; Present code on PORTD
  13.         BSF     PORTA, RA1  ; Activate Column 0
  14.         CALL        ED10MS      ; Let it glow for a while..
  15.         BCF     PORTA, RA1  ; Turn off Column 0
  16.        
  17.         GOTO        LOOP
  18.        
  19.        
  20. GET_NRCODE  RLNCF   WREG            ; Multiplay WREG with 2
  21.         MOVWF   TBLPTRL         ; Load in to TABLPTRL
  22.         MOVLW   high(NUMBERCODES)   ; Get high byte of code table
  23.         MOVWF   TBLPTRH         ; Load in to TABLEPTRH
  24.         MOVLW   upper(NUMBERCODES)  ; Get upper byte of code table
  25.         MOVWF   TBLPTRU         ; Load in to TABLEPTRU
  26.         TBLRD*              ; Fetch data from TABLPTR
  27.         MOVF    TABLAT, W       ; Load fetched data to work
  28.         RETURN
  29.        
  30. NUMBERCODES org 0x500
  31.         DB      B'00111111' ; 0
  32.         DB      B'00000110' ; 1
  33.         DB      B'01011011' ; 2
  34.         DB      B'01001111' ; 3
  35.         DB      B'01100110' ; 4
  36.         DB      B'01101101' ; 5
  37.         DB      B'01111100' ; 6
  38.         DB      B'00000111' ; 7
  39.         DB      B'01111111' ; 8
  40.         DB      B'01100111' ; 9
  41.         DB      B'01110111' ; A
  42.         DB      B'01111100' ; b
  43.         DB      B'00111001' ; C
  44.         DB      B'01011110' ; d
  45.         DB      B'01111001' ; E
  46.         DB      B'01110001' ; F
  47.        
  48.        
  49.         END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement