Advertisement
Guest User

PASHA

a guest
Oct 24th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 6.98 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 FSR0L
  148.         decf STEP
  149.         BNZ M1 ;??????? ?? 0
  150.        
  151.         movlw .64
  152.         movwf STEP
  153.         movlw .64
  154.        
  155.     M2:
  156.        movwf INDF0
  157.        incf FSR0L
  158.        decf STEP
  159.        BNZ M2
  160.        
  161.        movlw .64
  162.        movwf STEP
  163.        movlw .64
  164.        
  165.     M3:
  166.        movwf INDF0
  167.        incf WREG
  168.        incf WREG
  169.        incf WREG
  170.        incf FSR0L
  171.        decf STEP
  172.        BNZ M3
  173.        
  174.        movlw .64
  175.        movwf STEP
  176.        movlw .255
  177.      
  178.     M4:
  179.        movwf INDF0
  180.        decf WREG
  181.        incf FSR0L
  182.        decf STEP
  183.        BNZ M4
  184.         movlw .64
  185.        movwf STEP
  186.        movlw .64
  187.        STOP: bra STOP
  188.       nop
  189.    
  190.        
  191.    
  192.  END      
  193. ;******************************************************************************
  194. ;End of program
  195.  
  196.         END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement