Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;******************************************************************************
- ; This file is a basic template for assembly code for a PIC18F1330. Copy *
- ; this file into your project directory and modify or add to it as needed. *
- ; *
- ; Refer to the MPASM User's Guide for additional information on the *
- ; features of the assembler. *
- ; *
- ; *
- ;******************************************************************************
- ; *
- ; Filename: *
- ; Date: *
- ; File Version: *
- ; *
- ; Author: *
- ; Company: *
- ; *
- ;******************************************************************************
- ; *
- ; Files Required: P18F1330.INC *
- ; *
- ;******************************************************************************
- LIST P=18F1330 ;directive to define processor
- #include <P18F1330.INC> ;processor specific variable definitions
- ;******************************************************************************
- ;Configuration bits
- ;Microchip has changed the format for defining the configuration bits, please
- ;see the .inc file for futher details on notation. Below are a few examples.
- ; Oscillator Selection:
- CONFIG OSC = INTIO2 ;INTERNAL OSCILLATOR, PORT FUNCTION ON RA6
- ; Fail Safe Clock Monitor:
- CONFIG FCMEN = OFF ;Fail Safe Clock Monitor disabled
- ; Power-Up Timer:
- CONFIG PWRT = OFF ;Disabled
- ;Oscillator Selection
- ;; __CONFIG _CONFIG1H, _OSC_LP_1H & _FCMEN_OFF_1H
- ;Fail Safe Monitor
- ;; __CONFIG _CONFIG2L, _PWRT_OFF_2L
- ;******************************************************************************
- ;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.
- CBLOCK 0x080
- WREG_TEMP ;variable used for context saving
- STATUS_TEMP ;variable used for context saving
- BSR_TEMP ;variable used for context saving
- ENDC
- CBLOCK 0x000
- EXAMPLE ;example of a variable in access RAM
- COUNTER1 ;VARIABLE USED IN DELAY1
- COUNTER2_1 ;VARIABLE USED IN DELAY2
- COUNTER2_2 ;VARIABLE USED IN DELAY2
- 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
- ;******************************************************************************
- ;Reset vector
- ; This code will start executing when a reset occurs.
- ORG 0x0000
- 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 0x0008
- 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 0x0018
- 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 ***
- retfie FAST
- ;******************************************************************************
- ;Start of main program
- ; The main program code is placed here.
- Main:
- MOVLW 0X01 ;select bank 1
- MOVWF BSR
- MOVLW b'00000000'
- MOVWF TRISA
- GOTO MAINLOOP
- MOVLW 0X00 ;select bank 0
- MOVWF BSR
- MAINLOOP:
- MOVLW 0X01
- MOVWF PORTA,RA0
- CALL DELAY1
- MOVLW 0X00
- MOVWF PORTA,RA0
- CALL DELAY2
- GOTO MAINLOOP
- DELAY1:
- MOVLW 0X0F
- MOVWF COUNTER1
- DELAY1_0:
- DECFSZ COUNTER1
- GOTO DELAY1_0
- RETURN
- DELAY2:
- MOVLW 0X0E
- MOVWF COUNTER2_1
- MOVLW 0X08
- MOVWF COUNTER2_2
- DELAY2_0:
- DECFSZ COUNTER2_1
- GOTO $+2
- DECFSZ COUNTER2_2
- GOTO DELAY2_0
- GOTO $+2
- NOP
- NOP
- RETURN
- ;******************************************************************************
- ;End of program
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement