Advertisement
Guest User

Untitled

a guest
Apr 17th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pic 16 4.10 KB | None | 0 0
  1. ;
  2. ;   MPASM template supplied by BILBOROUGH COLLEGE  28228
  3.  
  4.  
  5. ;NAME ...................................................ENTER YOUR NAME AND PROJECT TITLE HERE
  6.  
  7. ;PROGRAM TITLE ...................................................
  8.  
  9. ; Version 2 board settings: J14 links: Digital
  10. ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::
  11. ;
  12. ; The following lines embed configuration data into the PICmicro
  13.     LIST P=16F88
  14.     __CONFIG H'2007', H'3F7A'       ; RC mode
  15.     __CONFIG H'2008', H'3FFC'       ; Clock Fail-Safe disabled
  16.  
  17. ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  18.  
  19.                
  20. #DEFINE PAGE0   BCF     STATUS,5   
  21. #DEFINE PAGE1   BSF     STATUS,5   
  22.                
  23. OPSHUN  EQU H'81'       ;
  24. STATUS  EQU H'03'       ;defines status register
  25. TRISA   EQU H'5'        ;defines trisA register
  26. PORTA   EQU H'05'       ;defines portA register
  27. TRISB   EQU H'6'        ;defines TrisB register
  28. PORTB   EQU H'06'       ;defines portB register
  29. PCL EQU H'02'       ;Names the register called program counter
  30. W   EQU 0       ;Sets up the name used for the working register
  31. F   EQU 1       ;Sets up the name used for file
  32. Z   EQU 2       ;Sets up the name used for the zero flag
  33. C       EQU     0           ;Sets up the name used for the carry flag
  34.  
  35.  
  36. ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  37.  
  38. ;       NAME YOUR REGISTERS HERE
  39.                
  40. delay   EQU H'0C'       ;names the register called ????????
  41. delayf  EQU H'0D'       ;names the register called ????????
  42. lights  EQU H'0E'       ;names the register called ????????      DELETE THIS SECTION IF NOT USING REGISTERS
  43.  
  44. ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  45.  
  46. ;       VECTORS
  47.                
  48.     ORG 00      ; Reset vector
  49.     GOTO    XYZ     ; Goto start of program
  50.     ORG 04      ; Interrupt vector address
  51.     GOTO    05      ; Goto start of program
  52.     ORG 05      ; Start of program memory
  53.        
  54. ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  55.  
  56. ;       THIS SECTION IS USED TO SET THE DIRECTION OF THE OUTPUT PORTS.
  57.  
  58. ;ENTER the binary number for the Data Direction in the TRIS registers.
  59. ;Use 0 if you would like an output or 1 if you would like an input.
  60.  
  61. XYZ BSF STATUS,5    ;Bank 1 operation
  62.     CLRF    H'1B'       ;Makes the ANSEL (analogue) inputs digital
  63.     MOVLW   B'00011111';
  64.     MOVWF   TRISA       ;This sets portA data direction to #######
  65.     MOVLW   B'00000000' ;
  66.     MOVWF   TRISB       ;This sets portB data direction to #######
  67.     BCF STATUS,5    ;Back to bank 0
  68.  
  69. ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  70.  
  71. ;   MAIN PROGRAM
  72.  
  73. start   CLRF    delay
  74.     CLRF    lights
  75.     CLRF    delayf
  76.     CLRF    PORTA
  77.     CLRF    PORTB
  78.     CALL    input1
  79.     CALL    delsta
  80.     CALL    tend
  81.     GOTO    start
  82.  
  83. ;   write your program here.    
  84.  
  85.  
  86.  
  87.    
  88. ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  89.  
  90. ;   SUBROUTINES
  91.  
  92. ; Any subroutines to go in this section.
  93.  
  94.  
  95. input1  BTFSC   PORTA,0
  96.     GOTO    wait0
  97.     BTFSC   PORTA,1
  98.     GOTO    wait1
  99.     BTFSC   PORTA,2
  100.     GOTO    wait2
  101.     BTFSC   PORTA,3
  102.     GOTO    wait3
  103.     BTFSC   PORTA,4
  104.     GOTO    wait4
  105.     GOTO    input1
  106.  
  107.  
  108.  
  109. wait0   BTFSC   PORTA,0
  110.     GOTO    wait0
  111.     GOTO    delay10
  112.  
  113. wait1   BTFSC   PORTA,1
  114.     GOTO    wait1
  115.     GOTO    delay30
  116.  
  117. wait2   BTFSC   PORTA,2
  118.     GOTO    wait2
  119.     GOTO    delay1
  120.  
  121. wait3   BTFSC   PORTA,3
  122.     GOTO    wait3
  123.     GOTO    delay2
  124.  
  125.  
  126. wait4   BTFSC   PORTA,4
  127.     GOTO    wait4
  128.     GOTO    delay5
  129.  
  130.  
  131. delay10 MOVLW   B'00000001'
  132.     MOVWF   delay
  133.     MOVLW   B'00000001'
  134.     MOVLW   lights
  135.     RETURN
  136.  
  137. delay30 MOVLW   B'00000011'
  138.     MOVWF   delay
  139.     MOVLW   B'00000011'
  140.     MOVLW   lights
  141.     RETURN
  142.  
  143. delay1  MOVLW   B'00000110'
  144.     MOVWF   delay
  145.     MOVLW   B'00000110'
  146.     MOVLW   lights
  147.     RETURN
  148.  
  149. delay2  MOVLW   B'00001100'
  150.     MOVWF   delay
  151.     MOVLW   B'00001100'
  152.     MOVLW   lights
  153.     RETURN
  154.  
  155. delay5  MOVLW   B'00011110'
  156.     MOVWF   delay
  157.     MOVLW   B'00011110'
  158.     MOVLW   lights
  159.     RETURN
  160.  
  161. delsta  MOVWF   lights, PORTB
  162.     DECF    delay
  163.     CALL    count
  164.     RETURN
  165.  
  166. count   MOVLW   B'111111111'
  167.     MOVWF   delayf
  168. count2  DECFSZ  delayf,F
  169.     GOTO    count2
  170.     DECF    lights
  171.     DECFSZ  delay
  172.     RETURN
  173.  
  174. tend    CALL    flash
  175.     CALL    flash
  176.     CALL    flash
  177.     CALL    flash
  178.     CALL    flash
  179.     RETURN
  180.  
  181. flash   MOVLW   B'00011111'
  182.     MOVWF   PORTB
  183.     MOVLW   B'11111111'
  184.     MOVWF   PORTB
  185.     MOVLW   B'00011111'
  186.     MOVWF   PORTB
  187.     MOVLW   B'11111111'
  188.     MOVWF   PORTB
  189.     MOVLW   B'00011111'
  190.     MOVWF   PORTB
  191.     MOVLW   B'11111111'
  192.     MOVWF   PORTB
  193.     MOVLW   B'00011111'
  194.     MOVWF   PORTB
  195.     MOVLW   B'11111111'
  196.     MOVWF   PORTB
  197.     RETURN
  198.  
  199.  
  200.     END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement