Padrão pic
#INCLUDE <P16F628A.INC> #DEFINE BANK0 BCF STATUS,RP0
#DEFINE BANK1 BSF STATUS,RP0
#DEFINE BANK2 BCF STATUS,RP1
#DEFINE BANK3 BSF STATUS,RP1 ;DEFINICAO DE PORTAS ;VETOR RESET ORG 0X00 GOTO INICIO ; DEFINICAO DE VARIAVEIS CBLOCK 0X20 VALOR1 VALOR2 VALOR3 ENDC ;VETOR DE INTERRUPCAO ORG 0X04 BCF INTCON,7 MOVWF W_TEMP MOVF STATUS,0 MOVWF STATUS_TEMP BTFSS INTCON,1 GOTO SAI_IRQ GOTO IRQ GOTO SAI_IRQ GOTO IRQ SAI_IRQ BANK0 MOVF STATUS_TEMP,0 MOVWF STATUS MOVF W_TEMP,0 BCF INTCON,1 BSF INTCON,7 RETFIE IRQ BTFSS PORTB,1 GOTO ON GOTO OFF ON BSF PORTB,1 BTFSS PORTB,0 GOTO $-1 GOTO SAI_IRQ
OFF BCF PORTB,1 BTFSS PORTB,0 GOTO $-1 GOTO SAI_IRQ
;MAIN
; BSF PORTB,2
; CALL ATRASO
; BCF PORTB,2
; CALL ATRASO
; GOTO MAIN GOTO SAI_IRQ
;DEFINICAO DE VARIAVEIS CBLOCK 0X20 W_TEMP STATUS_TEMP ENDC INICIO BANK1 MOVLW B'10000000' MOVWF OPTION_REG MOVLW B'00000000' MOVWF INTCON MOVLW B'00010000' MOVWF PIE1 MOVLW B'00001011' MOVWF PCON MOVLW B'00000000' MOVWF TRISA MOVLW B'00000001' MOVWF TRISB MOVLW B'00010000' MOVWF TXSTA MOVLW B'00000000' MOVWF VRCON
BANK0 MOVLW B'00010000' MOVWF T1CON MOVLW B'00000000' MOVWF RCSTA MOVLW B'00000000' MOVWF PIR1 MOVLW B'00000111' MOVWF CMCON MOVLW B'00000000' MOVWF TMR0 MOVLW B'00000000' MOVWF T2CON MOVLW B'00000000' MOVWF CCP1CON
BANKO ; BANK1 BSF INTCON,4 BSF INTCON,7
; BANK0 MAIN BSF PORTB,2 CALL ATRASO BCF PORTB,2 CALL ATRASO GOTO MAIN ATRASO MOVLW .14 MOVWF VALOR1
LOOP0 MOVLW .7 MOVWF VALOR2
LOOP1 MOVLW .247 MOVWF VALOR3
LOOP2 NOP DECFSZ VALOR3,1 GOTO LOOP2 DECFSZ VALOR2,1 GOTO LOOP1 DECFSZ VALOR1,1 GOTO LOOP0 GOTO LOOP4
LOOP4 NOP RETURN