;****************************************************************************** ; This file is a basic template for assembly code for a APP3. Copy * ; this file into your project directory and modify or add to it as needed. * ; * ; The PIC18FXXX architecture allows two interrupt configurations. This * ; template code is written for priority interrupt levels and the IPEN bit * ; in the RCON register must be set to enable priority levels. If IPEN is * ; left in its default zero state, only the interrupt vector at 0x008 will * ; be used and the WREG_TEMP, BSR_TEMP and STATUS_TEMP variables will not * ; be needed. * ; * ; Refer to the MPASM User's Guide for additional information on the * ; features of the assembler. * ; * ; Refer to the PIC18FXX2 Data Sheet for additional information on the * ; architecture and instruction set. * ; This template is based on the Microchip object code template * ; * ;****************************************************************************** ; * ; Filename: * ; Date: * ; File Version: * ; * ; Author: * ; Company: * ; * ;****************************************************************************** ; * ; Files required: P18F252.INC * ; * ;****************************************************************************** LIST P=18F252 ;directive to define processor #include ;processor specific variable definitions ;****************************************************************************** ;Configuration bits ; The __CONFIG directive defines configuration data within the .ASM file. ; The labels following the directive are defined in the P18F252.INC file. ; The PIC18FXX2 Data Sheet explains the functions of the configuration bits. ; Change the following lines to suit your application. ; Note that the bootloader will work with watchdog enabled ; Also, the boot loader will not allow you to set code protection, ; LVP, or any other fuse that will render the device inoperable __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H __CONFIG _CONFIG2L, _BOR_ON_2L & _PWRT_ON_2L __CONFIG _CONFIG2H, _WDT_OFF_2H __CONFIG _CONFIG3H, _CCP2MX_OFF_3H __CONFIG _CONFIG4L, _STVR_OFF_4L & _LVP_OFF_4L & _DEBUG_OFF_4L __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L & _CP2_OFF_5L & _CP3_OFF_5L __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L __CONFIG _CONFIG6H, _WRTC_OFF_6H & _WRTB_OFF_6H & _WRTD_OFF_6H __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L __CONFIG _CONFIG7H, _EBTRB_OFF_7H __IDLOCS _IDLOC0, 'A' ;****************************************************************************** ;Variable definitions ; These variables are only needed if low priority interrupts are used. ; More variables may be needed to store other special function registers used ; in the interrupt routines. ; Be careful! These are not in the access bank ; So while MOVFF will correctly address them ; You can't use MOVF, MOVWF, etc. won't work ; unless BSR=0 CBLOCK 0x80 WREG_TEMP ;variable used for context saving STATUS_TEMP ;variable used for context saving BSR_TEMP ;variable used for context saving ENDC ;****************************************************************************** ;EEPROM data ; Data to be programmed into the Data EEPROM is defined here ORG 0xf00000 DE "Test Data",0,1,2,3,4,5 ;****************************************************************************** ; If you want to simulate using MPLAB, enable this code block to ; stand in for the boot loader IF 0 ORG 0x0000 goto 0x200 ; simulate boot loader action org 0x0008 goto 0x0208 org 0x0018 goto 0x0218 ENDIF ;Reset vector ; This code will start executing when a reset occurs. ORG 0x0200 goto Main ;go to start of main code ;****************************************************************************** ;High priority interrupt vector ; This code will start executing when a high priority interrupt occurs or ; when any interrupt occurs if interrupt priorities are not enabled. ORG 0x0208 bra HighInt ;go to high priority interrupt routine ;****************************************************************************** ;Low priority interrupt vector and routine ; This code will start executing when a low priority interrupt occurs. ; This code can be removed if low priority interrupts are not used. ORG 0x0218 movff STATUS,STATUS_TEMP ;save STATUS register movff WREG,WREG_TEMP ;save working register movff BSR,BSR_TEMP ;save BSR register ; *** low priority interrupt code goes here *** movff BSR_TEMP,BSR ;restore BSR register movff WREG_TEMP,WREG ;restore working register movff STATUS_TEMP,STATUS ;restore STATUS register retfie ;****************************************************************************** ;High priority interrupt routine ; The high priority interrupt code is placed here to avoid conflicting with ; the low priority interrupt vector. HighInt: ; *** high priority interrupt code goes here *** ; no need to save registers! retfie FAST ;****************************************************************************** ;Start of main program ; The main program code is placed here. Main: bra Main ;****************************************************************************** ;End of program END