Advertisement
Guest User

Untitled

a guest
Nov 27th, 2015
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.76 KB | None | 0 0
  1. ;*******************************************************************************
  2. ; *
  3. ; Microchip licenses this software to you solely for use with Microchip *
  4. ; products. The software is owned by Microchip and/or its licensors, and is *
  5. ; protected under applicable copyright laws. All rights reserved. *
  6. ; *
  7. ; This software and any accompanying information is for suggestion only. *
  8. ; It shall not be deemed to modify Microchip?s standard warranty for its *
  9. ; products. It is your responsibility to ensure that this software meets *
  10. ; your requirements. *
  11. ; *
  12. ; SOFTWARE IS PROVIDED "AS IS". MICROCHIP AND ITS LICENSORS EXPRESSLY *
  13. ; DISCLAIM ANY WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING *
  14. ; BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS *
  15. ; FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL *
  16. ; MICROCHIP OR ITS LICENSORS BE LIABLE FOR ANY INCIDENTAL, SPECIAL, *
  17. ; INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, HARM TO *
  18. ; YOUR EQUIPMENT, COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR *
  19. ; SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY *
  20. ; DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER *
  21. ; SIMILAR COSTS. *
  22. ; *
  23. ; To the fullest extend allowed by law, Microchip and its licensors *
  24. ; liability shall not exceed the amount of fee, if any, that you have paid *
  25. ; directly to Microchip to use this software. *
  26. ; *
  27. ; MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF *
  28. ; THESE TERMS. *
  29. ; *
  30. ;*******************************************************************************
  31. ; *
  32. ; Filename: *
  33. ; Date: *
  34. ; File Version: *
  35. ; Author: *
  36. ; Company: *
  37. ; Description: *
  38. ; *
  39. ;*******************************************************************************
  40. ; *
  41. ; Notes: In the MPLAB X Help, refer to the MPASM Assembler documentation *
  42. ; for information on assembly instructions. *
  43. ; *
  44. ;*******************************************************************************
  45. ; *
  46. ; Known Issues: This template is designed for relocatable code. As such, *
  47. ; build errors such as "Directive only allowed when generating an object *
  48. ; file" will result when the 'Build in Absolute Mode' checkbox is selected *
  49. ; in the project properties. Designing code in absolute mode is *
  50. ; antiquated - use relocatable mode. *
  51. ; *
  52. ;*******************************************************************************
  53. ; *
  54. ; Revision History: *
  55. ; *
  56. ;*******************************************************************************
  57.  
  58.  
  59.  
  60. ;*******************************************************************************
  61. ; Processor Inclusion
  62. ;
  63. ; TODO Step #1 Open the task list under Window > Tasks. Include your
  64. ; device .inc file - e.g. #include <device_name>.inc. Available
  65. ; include files are in C:\Program Files\Microchip\MPLABX\mpasmx
  66. ; assuming the default installation path for MPLAB X. You may manually find
  67. ; the appropriate include file for your device here and include it, or
  68. ; simply copy the include generated by the configuration bits
  69. ; generator (see Step #2).
  70. ;
  71. ;*******************************************************************************
  72.  
  73. ; TODO INSERT INCLUDE CODE HERE
  74.  
  75. ;*******************************************************************************
  76. ;
  77. ; TODO Step #2 - Configuration Word Setup
  78. ;
  79. ; The 'CONFIG' directive is used to embed the configuration word within the
  80. ; .asm file. MPLAB X requires users to embed their configuration words
  81. ; into source code. See the device datasheet for additional information
  82. ; on configuration word settings. Device configuration bits descriptions
  83. ; are in C:\Program Files\Microchip\MPLABX\mpasmx\P<device_name>.inc
  84. ; (may change depending on your MPLAB X installation directory).
  85. ;
  86. ; MPLAB X has a feature which generates configuration bits source code. Go to
  87. ; Window > PIC Memory Views > Configuration Bits. Configure each field as
  88. ; needed and select 'Generate Source Code to Output'. The resulting code which
  89. ; appears in the 'Output Window' > 'Config Bits Source' tab may be copied
  90. ; below.
  91. ;
  92. ;*******************************************************************************
  93.  
  94. ; TODO INSERT CONFIG HERE
  95.  
  96. ;*******************************************************************************
  97. ;
  98. ; TODO Step #3 - Variable Definitions
  99. ;
  100. ; Refer to datasheet for available data memory (RAM) organization assuming
  101. ; relocatible code organization (which is an option in project
  102. ; properties > mpasm (Global Options)). Absolute mode generally should
  103. ; be used sparingly.
  104. ;
  105. ; Example of using GPR Uninitialized Data
  106. ;
  107. ; GPR_VAR UDATA
  108. ; MYVAR1 RES 1 ; User variable linker places
  109. ; MYVAR2 RES 1 ; User variable linker places
  110. ; MYVAR3 RES 1 ; User variable linker places
  111. ;
  112. ; ; Example of using Access Uninitialized Data Section (when available)
  113. ; ; The variables for the context saving in the device datasheet may need
  114. ; ; memory reserved here.
  115.  
  116. #include<P18F45K20.inc>
  117.  
  118. INT_VAR UDATA_ACS
  119. TAB_LENGTH RES 1
  120. TAB_INCREMENT RES 1
  121. MIN RES 1
  122. MAX RES 1
  123.  
  124. ; STATUS_TEMP RES 1 ; status used for context saving
  125. ; BSR_TEMP RES 1 ; bank select used for ISR context saving
  126. ;
  127. ;*******************************************************************************
  128.  
  129. ; TODO PLACE VARIABLE DEFINITIONS GO HERE
  130.  
  131. ;*******************************************************************************
  132. ; Reset Vector
  133. ;*******************************************************************************
  134.  
  135. RES_VECT CODE 0x0000 ; processor reset vector
  136. GOTO MAIN ; go to beginning of program
  137.  
  138. ;*******************************************************************************
  139. ; TODO Step #4 - Interrupt Service Routines
  140. ;
  141. ; There are a few different ways to structure interrupt routines in the 8
  142. ; bit device families. On PIC18's the high priority and low priority
  143. ; interrupts are located at 0x0008 and 0x0018, respectively. On PIC16's and
  144. ; lower the interrupt is at 0x0004. Between device families there is subtle
  145. ; variation in the both the hardware supporting the ISR (for restoring
  146. ; interrupt context) as well as the software used to restore the context
  147. ; (without corrupting the STATUS bits).
  148. ;
  149. ; General formats are shown below in relocatible format.
  150. ;
  151. ;------------------------------PIC16's and below--------------------------------
  152. ;
  153. ; ISR CODE 0x0004 ; interrupt vector location
  154. ;
  155. ; <Search the device datasheet for 'context' and copy interrupt
  156. ; context saving code here. Older devices need context saving code,
  157. ; but newer devices like the 16F#### don't need context saving code.>
  158. ;
  159. ; RETFIE
  160. ;
  161. ;----------------------------------PIC18's--------------------------------------
  162. ;
  163. ; ISRHV CODE 0x0008
  164. ; GOTO HIGH_ISR
  165. ; ISRLV CODE 0x0018
  166. ; GOTO LOW_ISR
  167. ;
  168. ; ISRH CODE ; let linker place high ISR routine
  169. ; HIGH_ISR
  170. ; <Insert High Priority ISR Here - no SW context saving>
  171. ; RETFIE FAST
  172. ;
  173. ; ISRL CODE ; let linker place low ISR routine
  174. ; LOW_ISR
  175. ; <Search the device datasheet for 'context' and copy interrupt
  176. ; context saving code here>
  177. ; RETFIE
  178. ;
  179. ;*******************************************************************************
  180.  
  181. ; TODO INSERT ISR HERE
  182.  
  183. ;*******************************************************************************
  184. ; MAIN PROGRAM
  185. ;*******************************************************************************
  186.  
  187. MAIN_PROG CODE ; let linker place main program
  188.  
  189. WRITE_ARRAY
  190. LFSR 0, h'100'
  191. MOVLW 0
  192. MOVWF TAB_LENGTH,0
  193.  
  194. MOVLW d'25'
  195. MOVWF POSTINC0,0
  196. INCF TAB_LENGTH
  197.  
  198. MOVLW d'4'
  199. MOVWF POSTINC0,0
  200. INCF TAB_LENGTH
  201.  
  202. MOVLW d'2'
  203. MOVWF POSTINC0,0
  204. INCF TAB_LENGTH
  205.  
  206. MOVLW d'15'
  207. MOVWF POSTINC0,0
  208. INCF TAB_LENGTH
  209.  
  210. MOVLW d'16'
  211. MOVWF POSTINC0,0
  212. INCF TAB_LENGTH
  213.  
  214. MOVLW d'101'
  215. MOVWF POSTINC0,0
  216. INCF TAB_LENGTH
  217.  
  218. MOVLW d'33'
  219. MOVWF POSTINC0,0
  220. INCF TAB_LENGTH
  221.  
  222. MOVLW d'3'
  223. MOVWF POSTINC0,0
  224. INCF TAB_LENGTH
  225.  
  226. RETURN
  227.  
  228. UPDATE_MIN_MAX
  229. MOVF POSTINC0, 0
  230. CPFSLT MIN
  231. MOVWF MIN
  232.  
  233. CPFSGT MAX
  234. MOVWF MAX
  235.  
  236. RETURN
  237.  
  238. CHERCHE_MIN_MAX
  239. CLRF FSR0H,0
  240. LFSR 0, h'100'
  241.  
  242. MOVLW 0xFF
  243. MOVWF MIN
  244.  
  245. MOVLW 0x00
  246. MOVWF MAX
  247.  
  248. LOOP
  249. CALL UPDATE_MIN_MAX
  250.  
  251. INCF TAB_INCREMENT
  252. MOVF TAB_INCREMENT, 0
  253.  
  254. CPFSLT TAB_LENGTH
  255. GOTO LOOP
  256.  
  257. RETURN
  258.  
  259. MAIN
  260. CALL WRITE_ARRAY
  261. CALL CHERCHE_MIN_MAX
  262.  
  263. GOTO $ ; loop forever
  264.  
  265. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement