protocolo rc5 part 2
Autor: casa do fusca | Publicado: 2011-12-12T03:36:00-08:00

agora nesta segunda parte do tutorial do protocolo rc5
estou colocando o codigo em assembler é um pouco longo são 444 linhas mais fico bem intuitivo
qualquer duvida e so comentar
lembrando que este codigo ainda nào foi otimizado por falta de tempo mais funciona perfeitamente e não roda lento






;***************************DEVICE TEC/ SISTEMAS ELETRONICOS
;DATA 07/07/2011
;PROGRAMADOR: DANILO S CABRAL
;COMPILADOR USADO MPLAB IDE V8.63
;ALGORITIMO CRIADO PARA INTERPRETAÇÃO DOS SINAIS EMITIDOS POR CONTROLE REMOTO
;ULTILIZANDO O PROTOCOLO (RC5) DESENVOLVIDO PELA PHILIPS  
;PROTOCOLO ENVIA UMA SEQUENCIA DE 14BITS COM DURAÇÃO DE 25MS
;SENDO CADA BIT COM 1.77MS DE DURAÇÃO
;NESTE ALGORITIMO IREMOS TRABALHAR COM A LOGICA DE SINAIS INVERTIDA
;DEVIDO AO FATO QUE O SENSOR INFRAVERMELHO INVERTE OS SINAIS ISTO E QUANDO O CONTROLE
;ENVIA NL1 O SENSOR RECEBE E ENIA NL0 PARA O MICROCONTROLADOR E VICE VERSA.
;=======================COMPOSIÇÃO DO CODIGO RECEBIDO
;BIT1|BIT2|BIT3|BIT4|BIT5|BIT6|BIT7|BIT8|BIT9|BIT10|BIT11|BIT12|BIT13|BIT4|
;STARTBIT|TOGLE| &nbsp; &nbsp; &nbsp; &nbsp;ENDEREÇO &nbsp; &nbsp; &nbsp; &nbsp;| &nbsp; COMANDO COMPOSTO POR 6 BITS &nbsp; |
;| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DESCARTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp;SINAIS QUE SERA USADO &nbsp; &nbsp; &nbsp;|
;| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;DURAÇÃO &nbsp;13.6MS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | &nbsp; &nbsp; &nbsp; DURAÇÃO DE 10.2 MS &nbsp; &nbsp; &nbsp; &nbsp;|


&nbsp; LIST P=16F84a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;define processador
&nbsp; RADIX &nbsp; &nbsp; DEC &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;define padrão decimal
&nbsp; INCLUDE &lt;P16F84a.INC&gt; &nbsp; ;inclue arquivo com características do 16f628
&nbsp; __CONFIG _CP_OFF &amp; _PWRTE_ON &amp; _WDT_OFF &amp; _XT_OSC
&nbsp; ERRORLEVEL &nbsp; -302
;______________________________________SEL. BANCO DE MEMORIA
#DEFINE &nbsp;BANK0 BCF STATUS,RP0
#DEFINE &nbsp;BANK1 BSF STATUS,RP0
;______________________________________VARIAVÉIS
&nbsp;CBLOCK &nbsp; 0X0C
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; W_TEMP
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; STATUS_TEMP
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADRESS &nbsp; &nbsp; &nbsp; &nbsp; ;AQUI FICA ARMAZENADO OS 8 BITS INICIAIS &nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; COMAND &nbsp; &nbsp; &nbsp; &nbsp; ;AQUI FICA ARMAZENADO OS 6 BITS REFERENTE A TECLA DO CONTROLE
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; GETCH &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;ULTILISADA PARA LIMITAR QUANTIDADE DE BITS 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FLAGCIR &nbsp; &nbsp; &nbsp; &nbsp;;VARIAVEL USADA COMO ESPELHO DA VARIAVEL COMAND
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; STARTBIT &nbsp; &nbsp; &nbsp; ;AQUI FICA ARMAZENADOS OS 2 START BITS E O BIT TOOGLE
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FLAGTEC &nbsp; &nbsp; &nbsp; &nbsp;;FLAG DE CONTROLE DE TECLAS APERTADA
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FLAGTEC1 &nbsp; &nbsp; &nbsp; ;FLAG DE CONTROLE DE TECLAS APERTADA
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TEMPO0 &nbsp; &nbsp; &nbsp; &nbsp; ;VARIAVEL USADA PARA TEMPORIZAÇÃO
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TEMPO1 &nbsp; &nbsp; &nbsp; &nbsp; ;VARIAVEL USADA PARA TEMPORIZAÇÃO
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TEMPO2 &nbsp; &nbsp; &nbsp; &nbsp; ;VARIAVEL USADA PARA TEMPORIZAÇÃO
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TEMPO3 &nbsp; &nbsp; &nbsp; &nbsp; ;VARIAVEL USADA PARA TEMPORIZAÇÃO
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp;ENDC

;_____________________________________FLAGS CONTROL;
;FLAGS DE RECEBIMENTO IR
#DEFINE &nbsp;CONTROLE &nbsp; STARTBIT,0
#DEFINE &nbsp;_1 &nbsp; &nbsp; &nbsp; &nbsp; STARTBIT,1
#DEFINE &nbsp;_2 &nbsp; &nbsp; &nbsp; &nbsp; STARTBIT,2
#DEFINE &nbsp;_3 &nbsp; &nbsp; &nbsp; &nbsp; STARTBIT,3
#DEFINE &nbsp;_4 &nbsp; &nbsp; &nbsp; &nbsp; STARTBIT,4
#DEFINE &nbsp;TOOGLE &nbsp; &nbsp; STARTBIT,5
#DEFINE &nbsp;START2 &nbsp; &nbsp; STARTBIT,6
#DEFINE &nbsp;START1 &nbsp; &nbsp; STARTBIT,7
#DEFINE &nbsp;CINCO &nbsp; &nbsp; &nbsp;FLAGCIR,5

#DEFINE &nbsp;ZERO &nbsp; &nbsp; &nbsp; FLAGCIR,0
#DEFINE &nbsp;TC1 &nbsp; &nbsp; &nbsp; &nbsp;FLAGTEC,0
#DEFINE &nbsp;TC2 &nbsp; &nbsp; &nbsp; &nbsp;FLAGTEC,1
#DEFINE &nbsp;TC3 &nbsp; &nbsp; &nbsp; &nbsp;FLAGTEC,2
#DEFINE &nbsp;TC4 &nbsp; &nbsp; &nbsp; &nbsp;FLAGTEC,3
#DEFINE &nbsp;TC5 &nbsp; &nbsp; &nbsp; &nbsp;FLAGTEC,4
#DEFINE &nbsp;TC6 &nbsp; &nbsp; &nbsp; &nbsp;FLAGTEC,5
#DEFINE &nbsp;TC7 &nbsp; &nbsp; &nbsp; &nbsp;FLAGTEC,6
#DEFINE &nbsp;TC8 &nbsp; &nbsp; &nbsp; &nbsp;FLAGTEC,7
#DEFINE &nbsp;TC9 &nbsp; &nbsp; &nbsp; &nbsp;FLAGTEC1,0
#DEFINE &nbsp;TC0 &nbsp; &nbsp; &nbsp; &nbsp;FLAGTEC1,1
;_____________________________________CONSTANTES;
;VALORES EQUIVALENTES A TECLAS ACIONADAS NO CONTROLE
#DEFINE TECLA0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;B'00111100'
#DEFINE TECLA1 &nbsp;   &nbsp; &nbsp; B'00111101' 
#DEFINE TECLA2 &nbsp; &nbsp; &nbsp; &nbsp;  B'00111110'  
#DEFINE TECLA3 &nbsp;    B'00111111' 
#DEFINE TECLA4 &nbsp;    B'00111000' 
#DEFINE TECLA5   &nbsp; &nbsp; B'00111001' 
#DEFINE TECLA6 &nbsp;   B'00111010'
#DEFINE TECLA7 &nbsp;    B'00111011' 
#DEFINE TECLA8 &nbsp;   B'00110100' 
#DEFINE TECLA9 &nbsp;    B'00110101' 
#DEFINE STANDBY &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; B'11110011' 
#DEFINE MUTE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; B'11110010' 
#DEFINE VOLUME_UP &nbsp; &nbsp; &nbsp; &nbsp; B'11101111' 
#DEFINE VOLUME_DO &nbsp; &nbsp; &nbsp; &nbsp; B'11101110' 

;_____________________________________DEFINIÇÕES
#DEFINE &nbsp;IR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PORTA,0 &nbsp; &nbsp;;SENSOR TSOP
#DEFINE &nbsp;OUT0 &nbsp; &nbsp; &nbsp; &nbsp;PORTA,1 &nbsp; &nbsp;;ACIONAMENTO DO RELE
#DEFINE &nbsp;OUT1 &nbsp; &nbsp; &nbsp; &nbsp;PORTA,2 &nbsp; &nbsp;;ACIONAMENTO DO RELE
#DEFINE &nbsp;OUT2 &nbsp; &nbsp; &nbsp; &nbsp;PORTB,0 &nbsp; &nbsp;;ACIONAMENTO DO RELE
#DEFINE &nbsp;OUT3 &nbsp; &nbsp; &nbsp; &nbsp;PORTB,1 &nbsp; &nbsp;;ACIONAMENTO DO RELE
#DEFINE &nbsp;OUT4 &nbsp; &nbsp; &nbsp; &nbsp;PORTB,2 &nbsp; &nbsp;;ACIONAMENTO DO RELE
#DEFINE &nbsp;OUT5 &nbsp; &nbsp; &nbsp; &nbsp;PORTB,3 &nbsp; &nbsp;;ACIONAMENTO DO RELE
#DEFINE &nbsp;OUT6 &nbsp; &nbsp; &nbsp; &nbsp;PORTB,4 &nbsp; &nbsp;;ACIONAMENTO DO RELE
#DEFINE &nbsp;OUT7 &nbsp; &nbsp; &nbsp; &nbsp;PORTB,5 &nbsp; &nbsp;;ACIONAMENTO DO RELE
#DEFINE &nbsp;OUT8 &nbsp; &nbsp; &nbsp; &nbsp;PORTB,6 &nbsp; &nbsp;;ACIONAMENTO DO RELE
#DEFINE &nbsp;OUT9 &nbsp; &nbsp; &nbsp; &nbsp;PORTB,7 &nbsp; &nbsp;;ACIONAMENTO DO RELE
;_____________________________________MEMORIA DE PROGRAMA
&nbsp; &nbsp; &nbsp; &nbsp;ORG &nbsp; &nbsp; &nbsp;0X00 &nbsp; &nbsp; &nbsp;;define nicio do trecho a seguir em 000
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GOTO INICIO &nbsp; &nbsp; &nbsp; &nbsp;;desvia para o inicio
;_____________________________________ROTINA DE INTERRUPÇÃO
&nbsp; &nbsp; &nbsp; &nbsp;ORG &nbsp; &nbsp; &nbsp;0X04 
&nbsp; &nbsp; 
&nbsp; &nbsp; &nbsp; &nbsp;RETFIE &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;volta da interupção
;_____________________________________SUB.ROTINAS
LE_BIT
&nbsp; &nbsp; BTFSC &nbsp; &nbsp;IR
&nbsp; &nbsp; GOTO &nbsp; &nbsp; BIT1
&nbsp; &nbsp; GOTO &nbsp; &nbsp; BIT0
BIT0
&nbsp; 
&nbsp; &nbsp; BCF &nbsp; &nbsp; &nbsp;STATUS,C &nbsp; 
&nbsp; &nbsp; RETURN
BIT1
&nbsp; 
&nbsp; &nbsp; BSF &nbsp; &nbsp; &nbsp;STATUS,C &nbsp; 
&nbsp; &nbsp; RETURN &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; 
_10MS
&nbsp; &nbsp; MOVLW &nbsp; &nbsp; .10
&nbsp; &nbsp; MOVWF &nbsp; &nbsp; TEMPO1
&nbsp; &nbsp; MOVLW &nbsp; &nbsp; .250
&nbsp; &nbsp; MOVWF &nbsp; &nbsp; TEMPO0
T_0
&nbsp; &nbsp; NOP
&nbsp; &nbsp; DECFSZ &nbsp; &nbsp;TEMPO0,F
&nbsp; &nbsp; GOTO &nbsp; &nbsp; &nbsp;T_0
&nbsp; &nbsp; NOP
&nbsp; &nbsp; DECFSZ &nbsp; &nbsp;TEMPO1,F
&nbsp; &nbsp; GOTO &nbsp; &nbsp; &nbsp;$-7
&nbsp; &nbsp; RETURN
_1.7MS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;ESPERA 1.725 MS
&nbsp; &nbsp; MOVLW &nbsp; &nbsp; .2
&nbsp; &nbsp; MOVWF &nbsp; &nbsp; TEMPO1
&nbsp; &nbsp; MOVLW &nbsp; &nbsp; .213
&nbsp; &nbsp; MOVWF &nbsp; &nbsp; TEMPO0
T_1
&nbsp; &nbsp; NOP
&nbsp; &nbsp; DECFSZ &nbsp; &nbsp;TEMPO0,F
&nbsp; &nbsp; GOTO &nbsp; &nbsp; &nbsp;T_1
&nbsp; &nbsp; NOP
&nbsp; &nbsp; DECFSZ &nbsp; &nbsp;TEMPO1,F
&nbsp; &nbsp; GOTO &nbsp; &nbsp; &nbsp;$-7
&nbsp; &nbsp; RETURN
DELAY_MS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;ESPERA 10.813 MS 
&nbsp; &nbsp; MOVLW &nbsp; &nbsp; .16
&nbsp; &nbsp; MOVWF &nbsp; &nbsp; TEMPO2
RECARGA
&nbsp; &nbsp; MOVLW &nbsp; &nbsp; .239
&nbsp; &nbsp; MOVWF &nbsp; &nbsp; TEMPO3
T_2
&nbsp; &nbsp; NOP
&nbsp; &nbsp; DECFSZ &nbsp; &nbsp;TEMPO3,F
&nbsp; &nbsp; GOTO &nbsp; &nbsp; &nbsp;T_2
&nbsp; &nbsp; DECFSZ &nbsp; &nbsp;TEMPO2,F
&nbsp; &nbsp; GOTO &nbsp; &nbsp; &nbsp;RECARGA
&nbsp; &nbsp; RETURN
TIME
&nbsp; &nbsp; MOVLW &nbsp; &nbsp; .14
&nbsp; &nbsp; MOVWF &nbsp; &nbsp; TEMPO2
RELOAD
&nbsp; &nbsp; MOVLW &nbsp; &nbsp; .253
&nbsp; &nbsp; MOVWF &nbsp; &nbsp; TEMPO3
T_4
&nbsp; &nbsp; NOP
&nbsp; &nbsp; DECFSZ &nbsp; &nbsp;TEMPO3,F
&nbsp; &nbsp; GOTO &nbsp; &nbsp; &nbsp;T_4
&nbsp; &nbsp; DECFSZ &nbsp; &nbsp;TEMPO2,F
&nbsp; &nbsp; GOTO &nbsp; &nbsp; &nbsp;RELOAD
&nbsp; &nbsp; RETURN
TEMPO
&nbsp; &nbsp; MOVLW &nbsp; &nbsp; .255
&nbsp; &nbsp; MOVWF &nbsp; &nbsp; TEMPO2
TTT
&nbsp; &nbsp; MOVLW &nbsp; &nbsp; .255
&nbsp; &nbsp; MOVWF &nbsp; &nbsp; TEMPO3
T_5
&nbsp; &nbsp; NOP
&nbsp; &nbsp; DECFSZ &nbsp; &nbsp;TEMPO3,F
&nbsp; &nbsp; GOTO &nbsp; &nbsp; &nbsp;T_5
&nbsp; &nbsp; DECFSZ &nbsp; &nbsp;TEMPO2,F
&nbsp; &nbsp; GOTO &nbsp; &nbsp; &nbsp;TTT
&nbsp; &nbsp; RETURN
;_____________________________________INICIO DO PROGRAMA
INICIO:    ; ESTE ENDERECO E' O IMEDIATAMENTE APOS O FIM DA INTERRUPCAO

&nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; BANK1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; MOVLW B'00000001' &nbsp; &nbsp; 
 MOVWF TRISA   
 MOVLW B'00000000'
 MOVWF TRISB   
&nbsp; &nbsp; MOVLW B'10001000'  &nbsp; &nbsp; 
 MOVWF OPTION_REG  
&nbsp; &nbsp; MOVLW B'01010000'  &nbsp; &nbsp; &nbsp; &nbsp; 
 MOVWF INTCON
&nbsp; &nbsp; BANK0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; CLRF &nbsp; &nbsp;PORTA
&nbsp; &nbsp; CLRF &nbsp; &nbsp;PORTB
&nbsp; &nbsp; CLRF &nbsp; &nbsp;FLAGTEC
&nbsp; &nbsp; CLRF &nbsp; &nbsp;FLAGTEC1
&nbsp; &nbsp; 

;____________________________________ROT. PRINCIPAL
MAIN
&nbsp; 

LOOP0 &nbsp; 
&nbsp; &nbsp; MOVLW &nbsp; &nbsp; &nbsp; .6
&nbsp; &nbsp; MOVWF &nbsp; &nbsp; &nbsp; GETCH
&nbsp; &nbsp; CLRF &nbsp; &nbsp; &nbsp; &nbsp;COMAND &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
&nbsp; &nbsp; 
LE_0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; 10ms sem nehum pulso para
&nbsp; &nbsp; CALL &nbsp; &nbsp; &nbsp; &nbsp;_10MS &nbsp; &nbsp; &nbsp; &nbsp;; identificar START
&nbsp; &nbsp; BTFSS &nbsp; &nbsp; &nbsp; IR &nbsp; &nbsp; &nbsp; &nbsp; ;
&nbsp; &nbsp; GOTO &nbsp; &nbsp; &nbsp; &nbsp;LE_0 &nbsp; &nbsp; &nbsp; &nbsp;;
;START
&nbsp; &nbsp; BTFSC &nbsp; &nbsp; &nbsp;IR &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;//ESPERA NL=1 PARA IDENTIFICAR STARTBIT
&nbsp; &nbsp; GOTO &nbsp; &nbsp; &nbsp; $-1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;ESPERA NNL=1
&nbsp; &nbsp; 
&nbsp; &nbsp; CALL &nbsp; &nbsp; &nbsp; DELAY_MS
INICIO_COMANDO
&nbsp; &nbsp; CALL &nbsp; &nbsp; &nbsp;LE_BIT &nbsp; &nbsp; 
&nbsp; &nbsp; RLF &nbsp; &nbsp; &nbsp; COMAND,F
&nbsp; &nbsp; CALL &nbsp; &nbsp; &nbsp;_1.7MS
&nbsp; &nbsp; DECFSZ &nbsp; &nbsp;GETCH,F
&nbsp; &nbsp; GOTO &nbsp; &nbsp; &nbsp;INICIO_COMANDO
&nbsp; &nbsp; 


;TECLA0
&nbsp; &nbsp; MOVF &nbsp; &nbsp; COMAND,W 
&nbsp; &nbsp; XORLW &nbsp; &nbsp;TECLA0
&nbsp; &nbsp; BTFSS &nbsp; &nbsp;STATUS,Z
&nbsp; &nbsp; GOTO &nbsp; &nbsp; $+2 &nbsp; &nbsp; 
&nbsp; &nbsp; GOTO &nbsp; &nbsp; C_0
;TECLA1
&nbsp; &nbsp; MOVF &nbsp; &nbsp; COMAND,W 
&nbsp; &nbsp; XORLW &nbsp; &nbsp;TECLA1
&nbsp; &nbsp; BTFSS &nbsp; &nbsp;STATUS,Z
&nbsp; &nbsp; GOTO &nbsp; &nbsp; $+2 &nbsp; &nbsp; 
&nbsp; &nbsp; GOTO &nbsp; &nbsp; C_1
;TECLA2
&nbsp; &nbsp; MOVF &nbsp; &nbsp; COMAND,W 
&nbsp; &nbsp; XORLW &nbsp; &nbsp;TECLA2
&nbsp; &nbsp; BTFSS &nbsp; &nbsp;STATUS,Z
&nbsp; &nbsp; GOTO &nbsp; &nbsp; $+2 &nbsp; &nbsp; 
&nbsp; &nbsp; GOTO &nbsp; &nbsp; C_2
;TECLA3
&nbsp; &nbsp; MOVF &nbsp; &nbsp; COMAND,W 
&nbsp; &nbsp; XORLW &nbsp; &nbsp;TECLA3
&nbsp; &nbsp; BTFSS &nbsp; &nbsp;STATUS,Z
&nbsp; &nbsp; GOTO &nbsp; &nbsp; $+2 &nbsp; &nbsp; 
&nbsp; &nbsp; GOTO &nbsp; &nbsp; C_3
;TECLA4
&nbsp; &nbsp; MOVF &nbsp; &nbsp;COMAND,W
&nbsp; &nbsp; XORLW &nbsp; &nbsp;TECLA4
&nbsp; &nbsp; BTFSS &nbsp; &nbsp;STATUS,Z
&nbsp; &nbsp; GOTO &nbsp; &nbsp; $+2 &nbsp; &nbsp; 
&nbsp; &nbsp; GOTO &nbsp; &nbsp; C_4 
;TECLA5
&nbsp; &nbsp; MOVF &nbsp; COMAND,W
&nbsp; &nbsp; XORLW &nbsp; &nbsp;TECLA5
&nbsp; &nbsp; BTFSS &nbsp; &nbsp;STATUS,Z
&nbsp; &nbsp; GOTO &nbsp; &nbsp; $+2 &nbsp; &nbsp; 
&nbsp; &nbsp; GOTO &nbsp; &nbsp; C_5
;TECLA6
&nbsp; &nbsp; MOVF &nbsp; &nbsp;COMAND,W
&nbsp; &nbsp; XORLW &nbsp; &nbsp;TECLA6
&nbsp; &nbsp; BTFSS &nbsp; &nbsp;STATUS,Z
&nbsp; &nbsp; GOTO &nbsp; &nbsp; $+2 &nbsp; &nbsp; 
&nbsp; &nbsp; GOTO &nbsp; &nbsp; C_6
;TECLA7
&nbsp; &nbsp; MOVF &nbsp; &nbsp;COMAND,W
&nbsp; &nbsp; XORLW &nbsp; &nbsp;TECLA7
&nbsp; &nbsp; BTFSS &nbsp; &nbsp;STATUS,Z
&nbsp; &nbsp; GOTO &nbsp; &nbsp; $+2 &nbsp; &nbsp; 
&nbsp; &nbsp; GOTO &nbsp; &nbsp; C_7
;TECLA8
&nbsp; &nbsp; MOVF &nbsp; &nbsp;COMAND,W
&nbsp; &nbsp; XORLW &nbsp; &nbsp;TECLA8
&nbsp; &nbsp; BTFSS &nbsp; &nbsp;STATUS,Z
&nbsp; &nbsp; GOTO &nbsp; &nbsp; $+2 &nbsp; &nbsp; 
&nbsp; &nbsp; GOTO &nbsp; &nbsp; C_8
;TECLA9
&nbsp; &nbsp; MOVF &nbsp; &nbsp;COMAND,W
&nbsp; &nbsp; XORLW &nbsp; &nbsp;TECLA9
&nbsp; &nbsp; BTFSS &nbsp; &nbsp;STATUS,Z
&nbsp; &nbsp; GOTO &nbsp; &nbsp; MAIN 
&nbsp; &nbsp; GOTO &nbsp; &nbsp; C_9
C_0
&nbsp; &nbsp; BTFSC &nbsp; TC1
&nbsp; &nbsp; GOTO &nbsp; &nbsp;OFFC0
&nbsp; &nbsp; GOTO &nbsp; &nbsp;ONC0
ONC0
&nbsp; &nbsp; BSF &nbsp; &nbsp; OUT0
&nbsp; &nbsp; BSF &nbsp; &nbsp; TC0
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
OFFC0
&nbsp; &nbsp; BCF &nbsp; &nbsp; OUT0
&nbsp; &nbsp; BCF &nbsp; &nbsp; TC0
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
&nbsp; 

C_1
&nbsp; &nbsp; BTFSC &nbsp; TC1
&nbsp; &nbsp; GOTO &nbsp; &nbsp;OFFC1
&nbsp; &nbsp; GOTO &nbsp; &nbsp;ONC1
ONC1
&nbsp; &nbsp; BSF &nbsp; &nbsp; OUT1
&nbsp; &nbsp; BSF &nbsp; &nbsp; TC1
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
OFFC1
&nbsp; &nbsp; BCF &nbsp; &nbsp; OUT1
&nbsp; &nbsp; BCF &nbsp; &nbsp; TC1
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
C_2
&nbsp; &nbsp; BTFSC &nbsp; TC2
&nbsp; &nbsp; GOTO &nbsp; &nbsp;OFFC2
&nbsp; &nbsp; GOTO &nbsp; &nbsp;ONC2
ONC2
&nbsp; &nbsp; BSF &nbsp; &nbsp; OUT2
&nbsp; &nbsp; BSF &nbsp; &nbsp; TC2
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
OFFC2
&nbsp; &nbsp; BCF &nbsp; &nbsp; OUT2
&nbsp; &nbsp; BCF &nbsp; &nbsp; TC2
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
C_3
&nbsp; &nbsp; BTFSC &nbsp; TC3
&nbsp; &nbsp; GOTO &nbsp; &nbsp;OFFC3
&nbsp; &nbsp; GOTO &nbsp; &nbsp;ONC3
ONC3
&nbsp; &nbsp; BSF &nbsp; &nbsp; OUT3
&nbsp; &nbsp; BSF &nbsp; &nbsp; TC3
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
OFFC3
&nbsp; &nbsp; BCF &nbsp; &nbsp; OUT3
&nbsp; &nbsp; BCF &nbsp; &nbsp; TC3
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
C_4
&nbsp; &nbsp; BTFSC &nbsp; TC4
&nbsp; &nbsp; GOTO &nbsp; &nbsp;OFFC4
&nbsp; &nbsp; GOTO &nbsp; &nbsp;ONC4
ONC4
&nbsp; &nbsp; BSF &nbsp; &nbsp; OUT4
&nbsp; &nbsp; BSF &nbsp; &nbsp; TC4
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
OFFC4
&nbsp; &nbsp; BCF &nbsp; &nbsp; OUT4
&nbsp; &nbsp; BCF &nbsp; &nbsp; TC4
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
C_5
&nbsp; &nbsp; BTFSC &nbsp; TC5
&nbsp; &nbsp; GOTO &nbsp; &nbsp;OFFC5
&nbsp; &nbsp; GOTO &nbsp; &nbsp;ONC5
ONC5
&nbsp; &nbsp; BSF &nbsp; &nbsp; OUT5
&nbsp; &nbsp; BSF &nbsp; &nbsp; TC5
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
OFFC5
&nbsp; &nbsp; BCF &nbsp; &nbsp; OUT5
&nbsp; &nbsp; BCF &nbsp; &nbsp; TC5
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
C_6
&nbsp; &nbsp; BTFSC &nbsp; TC6
&nbsp; &nbsp; GOTO &nbsp; &nbsp;OFFC6
&nbsp; &nbsp; GOTO &nbsp; &nbsp;ONC6
ONC6
&nbsp; &nbsp; BSF &nbsp; &nbsp; OUT6
&nbsp; &nbsp; BSF &nbsp; &nbsp; TC6
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
OFFC6
&nbsp; &nbsp; BCF &nbsp; &nbsp; OUT6
&nbsp; &nbsp; BCF &nbsp; &nbsp; TC6
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
C_7
&nbsp; &nbsp; BTFSC &nbsp; TC7
&nbsp; &nbsp; GOTO &nbsp; &nbsp;OFFC7
&nbsp; &nbsp; GOTO &nbsp; &nbsp;ONC7
ONC7
&nbsp; &nbsp; BSF &nbsp; &nbsp; OUT7
&nbsp; &nbsp; BSF &nbsp; &nbsp; TC7
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
OFFC7
&nbsp; &nbsp; BCF &nbsp; &nbsp; OUT7
&nbsp; &nbsp; BCF &nbsp; &nbsp; TC7
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
C_8
&nbsp; &nbsp; BTFSC &nbsp; TC8
&nbsp; &nbsp; GOTO &nbsp; &nbsp;OFFC8
&nbsp; &nbsp; GOTO &nbsp; &nbsp;ONC8
ONC8
&nbsp; &nbsp; BSF &nbsp; &nbsp; OUT8
&nbsp; &nbsp; BSF &nbsp; &nbsp; TC8
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
OFFC8
&nbsp; &nbsp; BCF &nbsp; &nbsp; OUT8
&nbsp; &nbsp; BCF &nbsp; &nbsp; TC8
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
C_9
&nbsp; &nbsp; BTFSC &nbsp; TC9
&nbsp; &nbsp; GOTO &nbsp; &nbsp;OFFC9
&nbsp; &nbsp; GOTO &nbsp; &nbsp;ONC9
ONC9
&nbsp; &nbsp; BSF &nbsp; &nbsp; OUT9
&nbsp; &nbsp; BSF &nbsp; &nbsp; TC9
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
OFFC9
&nbsp; &nbsp; BCF &nbsp; &nbsp; OUT9
&nbsp; &nbsp; BCF &nbsp; &nbsp; TC9
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN

ERRO
&nbsp; &nbsp; MOVLW &nbsp; B'11111111'
&nbsp; &nbsp; MOVWF &nbsp; PORTB
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; CLRF &nbsp; &nbsp;PORTB
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; MOVLW &nbsp; B'11111111'
&nbsp; &nbsp; MOVWF &nbsp; PORTB
&nbsp; &nbsp; CALL &nbsp; &nbsp;TEMPO
&nbsp; &nbsp; CLRF &nbsp; &nbsp;PORTB
&nbsp; &nbsp; GOTO &nbsp; &nbsp;MAIN
&nbsp; &nbsp; END