Advertisement
ptrawt

7-segment & keypad matrix

Jan 13th, 2014
3,178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pic 16 1.24 KB | None | 0 0
  1. ;setup
  2.     bsf status,5
  3.     bcf status,6
  4.     ; set PORTB as output
  5.     clrf trisb
  6.     ; set PORTC bit 0-3 as output
  7.     ; set PORTC bit 4-7 as input
  8.     movlw 0xF0
  9.     movwf trisc
  10.     ; switch to FSR Bank 0
  11.     bcf status,5
  12. ;end
  13.  
  14. chk:
  15.     ; enable PORTC bit 0
  16.     bsf portc,0
  17.     bcf portc,1
  18.     bcf portc,2
  19.     ; check input
  20.     btfsc portc,4
  21.     goto num1
  22.     btfsc portc,5
  23.     goto num2
  24.     btfsc portc,6
  25.     goto num3
  26.     btfsc portc,7
  27.     goto num4
  28.  
  29.     ; enable PORTC bit 1
  30.     bcf portc,0
  31.     bsf portc,1
  32.     bcf portc,2
  33.     ; check input
  34.     btfsc portc,4
  35.     goto num5
  36.     btfsc portc,5
  37.     goto num6
  38.     btfsc portc,6
  39.     goto num7
  40.     btfsc portc,7
  41.     goto num8
  42.  
  43.     ; enable PORTC bit 2   
  44.     bcf portc,0
  45.     bcf portc,1
  46.     bsf portc,2
  47.     ; check input
  48.     btfsc portc,4
  49.     goto num9
  50.     btfsc portc,5
  51.     goto num0
  52.     goto chk
  53.  
  54. num1:
  55.     movlw 0b00000110
  56.     movwf portb
  57.     goto chk
  58. num2:
  59.     movlw 0b01011011
  60.     movwf portb
  61.     goto chk
  62. num3:
  63.     movlw 0b01001111
  64.     movwf portb
  65.     goto chk
  66. num4:
  67.     movlw 0b01100110
  68.     movwf portb
  69.     goto chk
  70.    
  71. num5:
  72.     movlw 0b01101101
  73.     movwf portb
  74.     goto chk
  75. num6:
  76.     movlw 0b01111101
  77.     movwf portb
  78.     goto chk
  79. num7:
  80.     movlw 0b00000111
  81.     movwf portb
  82.     goto chk
  83. num8:
  84.     movlw 0b01111111
  85.     movwf portb
  86.     goto chk
  87. num9:
  88.     movlw 0b01101111
  89.     movwf portb
  90.     goto chk
  91. num0:
  92.     movlw 0b00111111
  93.     movwf portb
  94.     goto chk
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement