Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;*************************************************************************************************
- ;** **
- ;** Header Information **
- ;** **
- ;*************************************************************************************************
- list p=16F877A, r=dec, w=-302
- include <P16F877A.INC>
- __config _LVP_OFF & _BOREN_OFF & _PWRTE_ON & _WDT_OFF & _RC_OSC
- ;*************************************************************************************************
- ;** **
- ;** Variable Declarations **
- ;** **
- ;*************************************************************************************************
- cblock 0x70
- W_TEMP
- STATUS_TEMP
- PCLATH_TEMP
- COUNT1
- COUNT2
- COUNT3
- endc
- ;*************************************************************************************************
- ;** **
- ;** Start of Main Code **
- ;** **
- ;*************************************************************************************************
- org 0x000 ;reset vector
- goto START
- ;*************************************************************************************************
- ;** **
- ;** Interrupt Handler **
- ;** **
- ;*************************************************************************************************
- org 0x004 ;interrupt vector
- ;interrupt context save
- movwf W_TEMP
- swapf STATUS,W
- banksel 0
- movwf STATUS_TEMP
- movfw PCLATH
- movwf PCLATH_TEMP
- ;place interrupt code here
- ;interrupt context restore
- ISRExit movfw PCLATH_TEMP
- movwf PCLATH
- swapf STATUS_TEMP,W
- movwf STATUS
- swapf W_TEMP,F
- swapf W_TEMP,W
- retfie
- ;*************************************************************************************************
- ;** **
- ;** Initialization Routine **
- ;** **
- ;*************************************************************************************************
- START clrf PORTA ;init ports
- clrf PORTB
- clrf PORTC
- clrf PORTD
- clrf PORTE
- banksel ADCON1 ;bank 1
- movlw 6 ;all ports digital I/O mode
- movwf ADCON1
- clrf TRISA ;all ports output
- clrf TRISB
- clrf TRISC
- clrf TRISD
- clrf TRISE
- banksel 0 ;bank 0
- MAIN ;main code starts here
- ;*************************************************************************************************
- ;** **
- ;** Subroutines **
- ;** **
- ;*************************************************************************************************
- ;fixed delay
- DELAY movlw 0xFF
- movwf COUNT1
- decfsz COUNT1,F
- goto $-1
- return
- ;variable delay (load value into W prior to calling this delay)
- VarDelay movwf COUNT2
- call DELAY
- decfsz COUNT2,F
- goto $-2
- return
- end
Add Comment
Please, Sign In to add comment