Advertisement
Guest User

NIKITA

a guest
Oct 24th, 2019
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 6.93 KB | None | 0 0
  1. ;******************************************************************************
  2. ;   This file is a basic template for creating relocatable assembly code for  *
  3. ;   a PIC18F2520. Copy this file into your project directory and modify or    *
  4. ;   add to it as needed.                                                      *
  5. ;                                                                             *
  6. ;   The PIC18FXXXX architecture allows two interrupt configurations. This     *
  7. ;   template code is written for priority interrupt levels and the IPEN bit   *
  8. ;   in the RCON register must be set to enable priority levels. If IPEN is    *
  9. ;   left in its default zero state, only the interrupt vector at 0x008 will   *
  10. ;   be used and the WREG_TEMP, BSR_TEMP and STATUS_TEMP variables will not    *
  11. ;   be needed.                                                                *
  12. ;                                                                             *
  13. ;   Refer to the MPASM User's Guide for additional information on the         *
  14. ;   features of the assembler and linker.                                     *
  15. ;                                                                             *
  16. ;   Refer to the PIC18Fxx20 Data Sheet for additional                         *
  17. ;   information on the architecture and instruction set.                      *
  18. ;                                                                             *
  19. ;******************************************************************************
  20. ;                                                                             *
  21. ;    Filename:                                                                *
  22. ;    Date:                                                                    *
  23. ;    File Version:                                                            *
  24. ;                                                                             *
  25. ;    Author:                                                                  *
  26. ;    Company:                                                                 *
  27. ;                                                                             *
  28. ;******************************************************************************
  29. ;                                                                             *
  30. ;    Files required: P18F2520.INC                                             *
  31. ;                                                                             *
  32. ;******************************************************************************
  33.  
  34.     LIST P=18F2520, F=INHX32 ;directive to define processor and file format
  35.     #include <P18F2520.INC>  ;processor specific variable definitions
  36.  
  37. ;******************************************************************************
  38. ;Configuration bits
  39. ;Microchip has changed the format for defining the configuration bits, please
  40. ;see the .inc file for futher details on notation.  Below are a few examples.
  41.  
  42.  
  43.  
  44. ;   Oscillator Selection:
  45.     CONFIG  OSC = LP             ;LP
  46.  
  47. ;******************************************************************************
  48. ;Variable definitions
  49. ; These variables are only needed if low priority interrupts are used.
  50. ; More variables may be needed to store other special function registers used
  51. ; in the interrupt routines.
  52.  
  53.         UDATA
  54.  
  55. WREG_TEMP   RES 1   ;variable in RAM for context saving
  56. STATUS_TEMP RES 1   ;variable in RAM for context saving
  57. BSR_TEMP    RES 1   ;variable in RAM for context saving
  58.  
  59.         UDATA_ACS
  60.  
  61. EXAMPLE     RES 1   ;example of a variable in access RAM
  62. TMP     RES 1  
  63. TMP1            RES     1        ;NEW VARIABLES
  64. TMP2            RES     1    
  65. STEP            RES     1        
  66. ;******************************************************************************
  67. ;EEPROM data
  68. ; Data to be programmed into the Data EEPROM is defined here
  69.  
  70. DATA_EEPROM CODE    0xf00000
  71.  
  72.         DE  "Test Data",0,1,2,3,4,5
  73.  
  74. ;******************************************************************************
  75. ;Reset vector
  76. ; This code will start executing when a reset occurs.
  77.  
  78. RESET_VECTOR    CODE    0x0000
  79.  
  80.         goto    Main        ;go to start of main code
  81.  
  82. ;******************************************************************************
  83. ;High priority interrupt vector
  84. ; This code will start executing when a high priority interrupt occurs or
  85. ; when any interrupt occurs if interrupt priorities are not enabled.
  86.  
  87. HI_INT_VECTOR   CODE    0x0008
  88.  
  89.         bra HighInt     ;go to high priority interrupt routine
  90.  
  91. ;******************************************************************************
  92. ;Low priority interrupt vector
  93. ; This code will start executing when a low priority interrupt occurs.
  94. ; This code can be removed if low priority interrupts are not used.
  95.  
  96. LOW_INT_VECTOR  CODE    0x0018
  97.  
  98.         bra LowInt      ;go to low priority interrupt routine
  99.  
  100. ;******************************************************************************
  101. ;High priority interrupt routine
  102. ; The high priority interrupt code is placed here.
  103.  
  104.         CODE
  105.  
  106. HighInt:
  107.  
  108. ;   *** high priority interrupt code goes here ***
  109.  
  110.  
  111.         retfie  FAST
  112.  
  113. ;******************************************************************************
  114. ;Low priority interrupt routine
  115. ; The low priority interrupt code is placed here.
  116. ; This code can be removed if low priority interrupts are not used.
  117.  
  118. LowInt:
  119.         movff   STATUS,STATUS_TEMP  ;save STATUS register
  120.         movff   WREG,WREG_TEMP      ;save working register
  121.         movff   BSR,BSR_TEMP        ;save BSR register
  122.  
  123. ;   *** low priority interrupt code goes here ***
  124.  
  125.  
  126.         movff   BSR_TEMP,BSR        ;restore BSR register
  127.         movff   WREG_TEMP,WREG      ;restore working register
  128.         movff   STATUS_TEMP,STATUS  ;restore STATUS register
  129.         retfie
  130.  
  131. ;******************************************************************************
  132. ;Start of main program
  133. ; The main program code is placed here.
  134.  
  135. Main:  
  136. ;   *** main code goes here ***
  137.   movlw .64 ; очевидно
  138.     movwf STEP
  139.     movlw 0x02
  140.     movwf FSR0H
  141.     movlw 0x00
  142.     movwf FSR0L
  143.     movlw .0
  144.     M1:
  145.         movwf  INDF0
  146.         incf WREG
  147.         incf WREG
  148.         incf WREG
  149.         incf WREG
  150.         incf FSR0L
  151.         decf STEP
  152.         BNZ M1 ;переход по 0
  153.        
  154.         movlw .64
  155.         movwf STEP
  156.         movlw .255
  157.        
  158.     M2:
  159.        movwf INDF0
  160.       decf WREG
  161.       decf WREG
  162.        incf FSR0L
  163.        decf STEP
  164.        BNZ M2
  165.        
  166.        movlw .64
  167.        movwf STEP
  168.        movlw .128
  169.        
  170.     M3:
  171.        movwf INDF0
  172.        incf WREG
  173.        incf WREG
  174.        incf FSR0L
  175.        decf STEP
  176.        BNZ M3
  177.        
  178.        movlw .64
  179.        movwf STEP
  180.        movlw .255
  181.      
  182.     M4:
  183.        movwf INDF0
  184.        decf WREG
  185.        incf FSR0L
  186.        decf STEP
  187.        BNZ M4
  188.        
  189.        movlw .64
  190.        movwf STEP
  191.        movlw .64
  192.        STOP: bra STOP
  193.        nop
  194.    
  195.  END   
  196.    
  197.        
  198.    
  199.  END      
  200. ;******************************************************************************
  201. ;End of program
  202.  
  203.         END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement