CBLOCK 0X0C BAND
; P_ON CONT P_OFF W_AUX S_AUX TEMP1 TEMP2 ENDC
ORG 0X00 GOTO MAIN ;-------------------INTERRUPÇÃO----------- ORG 0X04
MOVWF W_AUX SWAPF STATUS,W MOVWF S_AUX MOVLW 0XFF XORWF PORTA,1 ;INVERTE A SAIDA
CALL BANDEIRA CALL INVERTE BCF INTCON,2 SWAPF S_AUX,W MOVWF STATUS SWAPF W_AUX,F SWAPF W_AUX,W RETFIE ;-----------------MAIN----------------------
MAIN
BSF STATUS,RP0 BCF TRISA,0 ;SAÍDA PWM BCF TRISB,5 BCF TRISB,4 BSF TRISB,6 ;CONF. RB6 COMO BOTOEIRA 1 BSF TRISB,7 ;CONF. RB7 COMO BOTOEIRA 2 MOVLW 0X05 ;HABILITA PULL-UP,CONF.PRE-ESCALA P/TMR0 MOVWF OPTION_REG ; BCF STATUS,RP0 BSF PORTA,0 MOVLW 0X00 MOVWF BAND MOVLW 0XE8 MOVWF CONT
;-----------------ROTINA PRINCIPAL------------- MOVF CONT,0 MOVWF TMR0 MOVLW B'10100000' MOVWF INTCON BTFSC PORTB,6 ;BT1 PRESSIONADA? GOTO $+3 ;NÃO, CALL BT1_SIM ;SIM, GOTO $-3 CALL BT1_NAO GOTO $-5
;-----------------BT1_NAO---------------
BT1_NAO
BTFSC PORTB,7 ;BT2 PRESSIONADA? RETURN ;NAO,MANTEM CONT CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY
MOVLW 0XD6 XORWF CONT,0 BTFSC STATUS,2 GOTO $+5 BCF PORTB,5 DECF CONT,1 ;SIM,VÁ PARA DIREITA BCF PORTB,4 GOTO $+3 BSF PORTB,4 RETURN CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY RETURN
;----------------BT1_SIM--------------------
BT1_SIM
BTFSC PORTB,7 ;BT2 PRESSIONADA? GOTO $+6 ;NAO,VÁ PARA ESQUERDA BCF PORTB,4 BCF PORTB,5 MOVLW 0XE7 ;SIM,FAÇA CONT=12 MOVWF CONT RETURN
CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY CALL DELAY