Guest User

Untitled

a guest
Jan 12th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.42 KB | None | 0 0
  1. ;******************************************************************************
  2. ; This file is a basic code template for code generation *
  3. ; on the PIC16F88. This file contains the basic code building *
  4. ; blocks to build upon. *
  5. ; *
  6. ; Refer to the MPASM User's Guide for additional information on *
  7. ; features of the assembler. *
  8. ; *
  9. ; Refer to the respective data sheet for additional *
  10. ; information on the instruction set. *
  11. ; *
  12. ;******************************************************************************
  13. ; *
  14. ; Filename: xxx.asm *
  15. ; Date: *
  16. ; File Version: *
  17. ; *
  18. ; Author: *
  19. ; Company: *
  20. ; *
  21. ; *
  22. ;******************************************************************************
  23. ; *
  24. ; Files required: P16F88.INC *
  25. ; *
  26. ;******************************************************************************
  27. ; *
  28. ; Features of the 16F88: *
  29. ; *
  30. ; 1 10-bit PWM *
  31. ; 8 MHz Internal Oscillator *
  32. ; ICD support *
  33. ; 256 bytes of EEPROM data memory *
  34. ; Capture/Compare Module *
  35. ; *
  36. ;******************************************************************************
  37. ; *
  38. ; Notes: *
  39. ; *
  40. ;******************************************************************************
  41. ; *
  42. ; Revision History: *
  43. ; *
  44. ;******************************************************************************
  45.  
  46. ;------------------------------------------------------------------------------
  47. ; PROCESSOR DECLARATION
  48. ;------------------------------------------------------------------------------
  49.  
  50. LIST p=16F88 ; list directive to define processor
  51. #INCLUDE <p16f88.inc> ; processor specific variable definitions
  52.  
  53. ;------------------------------------------------------------------------------
  54. ;
  55. ; CONFIGURATION WORD SETUP
  56. ;
  57. ; The 'CONFIG' directive is used to embed the configuration word within the
  58. ; .asm file. The lables following the directive are located in the respective
  59. ; .inc file. See the data sheet for additional information on configuration
  60. ; word settings.
  61. ;
  62. ;------------------------------------------------------------------------------
  63.  
  64. __CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_ON & _PWRTE_ON & _WDT_OFF & _INTRC_IO
  65. __CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
  66.  
  67. ;------------------------------------------------------------------------------
  68. ;
  69. ; VARIABLE DEFINITIONS
  70. ;
  71. ; Available Data Memory divided into Bank 0 through Bank 3. Each Bank contains
  72. ; Special Function Registers and General Purpose Registers at the locations
  73. ; below:
  74. ;
  75. ; SFR GPR SHARED GPR's
  76. ; Bank 0 0x00-0x1F 0x20-0x6F 0x70-0x7F
  77. ; Bank 1 0x80-0x9F 0xA0-0xEF 0xF0-0xFF
  78. ; Bank 2 0x100-0x10F 0x110-0x16F 0x170-0x17F
  79. ; Bank 3 0x180-0x18F 0x190-0x1EF 0x1F0-0x1FF
  80. ;
  81. ;------------------------------------------------------------------------------
  82. ; EEPROM INITIALIZATION
  83. ;
  84. ; The 16F88 has 256 bytes of non-volatile EEPROM, starting at address 0x2100
  85. ;
  86. ;------------------------------------------------------------------------------
  87.  
  88. DATAEE CODE 0x2100
  89. DE "MCHP" ; Place 'M' 'C' 'H' 'P' at address 0,1,2,3
  90.  
  91. ;------------------------------------------------------------------------------
  92. ; RESET VECTOR
  93. ;------------------------------------------------------------------------------
  94.  
  95. RESET CODE 0x0000 ; processor reset vector
  96. pagesel START
  97. GOTO START ; go to beginning of program
  98.  
  99. ;------------------------------------------------------------------------------
  100. ; INTERRUPT SERVICE ROUTINE
  101. ;------------------------------------------------------------------------------
  102.  
  103. INT_VECT CODE 0x0004 ; interrupt vector location
  104.  
  105. ; Context saving for ISR
  106. MOVWF W_TEMP ; save off current W register contents
  107. MOVF STATUS,W ; move status register into W register
  108. MOVWF STATUS_TEMP ; save off contents of STATUS register
  109. MOVF PCLATH,W ; move pclath register into W register
  110. MOVWF PCLATH_TEMP ; save off contents of PCLATH register
  111.  
  112. ;------------------------------------------------------------------------------
  113. ; USER INTERRUPT SERVICE ROUTINE GOES HERE
  114. ;------------------------------------------------------------------------------
  115.  
  116. ; Restore context before returning from interrupt
  117. MOVF PCLATH_TEMP,W ; retrieve copy of PCLATH register
  118. MOVWF PCLATH ; restore pre-isr PCLATH register contents
  119. MOVF STATUS_TEMP,W ; retrieve copy of STATUS register
  120. MOVWF STATUS ; restore pre-isr STATUS register contents
  121. SWAPF W_TEMP,F
  122. SWAPF W_TEMP,W ; restore pre-isr W register contents
  123. RETFIE ; return from interrupt
  124.  
  125. PROGRAM CODE
  126.  
  127. START
  128. movlw 0b00000000
  129. movwf TRISA
  130. movlw 0b00000001
  131. movwf PORTA
  132. ;------------------------------------------------------------------------------
  133. ; PLACE USER PROGRAM HERE
  134. ;------------------------------------------------------------------------------
  135.  
  136. GOTO $
  137.  
  138. END
Add Comment
Please, Sign In to add comment