que haces lager!!como andas!!!como veras estoy en crisis con el proton...la verdad que no me gustaria dejarlo porque con programas chicos no tube grandes incovenientes,pero ahora me esta volviendo loco,te cuento del programa....lee tarjetas de proximidad(esta parte esta hecha en assembler),da de alta y baja a tarjeta,etc,etc,uso bootloader,wdt,interrup por usart,aca te tiro todo el programa,estan testeadas todas las rutinas en forma independiente y andan sin problema, ahora todo el programa anda sin problemas pero no puedo tocar una linea que empieza a hacer cualquier cosa...
te cuento algunos detalles de problemas que tube:
1)no puedo hacer B[f]=B[ind] ^ B[e] ,no anda, tengo que meter una varialbe auxiliar
D= B[ind] ^ B[e]
B[f]=D
2)
desde el Lazo principal MAIN llamo a una subrutina en assembler usando call (call comienzo),dentro de esa rutina en assembler tengo que agregar una linea en basic
(if int=1 then analizar)para que me salte a la interrupcion(porque tengo un lazo cerrado ahi) y se vaya a la rutina analizar para ver que tiene que hacer,como logica estaria mal porque nunca encuentra el return del original call (subrutina comienzo),si hay interrupcion se va a la rutina analizar hace lo que tiene que hacer y vuelve a Main,de esta forma es de la unica que andubo,cuando trate de poner (if int=1 then return)y afuera del assembler if int=1 then analizar ,andubo pero pero al agregar otras subrutinas se empezo a desbordar el wdt y se me reseteaba el micro a cada rato),volvi a la version original y asi esta andando..que loco...
3)Cuando envio datos a veces tengo que agregar un delay entre envios de Bytes si no no anda y en otra parte del programa si lo dejo sin delays anda y con delays no anda...mas loco todavia...
en una parte del programa tengo:
for i=1 to 3
B1="N"
gosub putchar
next i
en otra parte tengo:
B1=B
gosub putchar
delayms 3
next i
3)le agrege una delay en la subrutina beep,pese a que el programa no va ahi a menos que encuentre una tarjeta se empieza a salta el wdt y a resetear el micro..
bueno.. a ver que te parece...ahi va todo el programete...saludossssssssssssss
javier
DEVICE = 16F877
XTAL = 20 "frecuencia cristal
remarks on
CONFIG BODEN_OFF,CP_OFF,PWRTE_On,WDT_On,LVP_Off,hs_OSC "EN FPP ES 3FB5 CON WDT , 3FB1 SIN WDT
DECLARE BOOTLOADER =On
DECLARE WATCHDOG = on
HSERIAL_CLEAR = ON
"SIMBOLOS VARIABLES
symbol rele portd.2
symbol buzz portc.5
symbol lamp1 porte.1
symbol ledlect portd.4
symbol activ portb.6
symbol puert portd.3
"DECLARACION VARIABLES
dim DATO0 as byte
dim DATO1 AS BYTE
dim DATO2 AS BYTE
dim DATO11 AS BYTE
dim DATO22 AS BYTE
DIM SECURE AS BIT
dim DATO3 AS BYTE
dim DATO4 AS BYTE
dim DATO5 AS BYTE
dim DATO6 AS BYTE
dim DATO7 AS BYTE
dim arg1 as byte
dim code_ok AS BYTE
dim cont as byte
dim bitcont as byte
dim idttarj as byte
dim var1 as word
dim ID_CARD as word
dim D as byte
dim i as byte
dim B [100]as byte
dim B2 as byte
DIM B3[6]AS BYTE
dim BORR[90] AS BYTE
DIM C AS BYTE
dim busy as bit
dim comando as bit
dim i1 as word
dim abier as bit
dim mal as bit "verificación pc encendida
dim discont as bit"verificación discontinuidad de envios
dim bien as bit"verificación contestación de envios
dim falla as bit "falla cont
dim marcadas as byte "indice de gente que ha entrado
dim llamada as bit
dim indice1 as byte
dim indice2 as byte
dim i2 as byte
dim I_laz as byte
dim int as bit
dim marca as byte
dim b1 as byte
dim ind as byte
dim a as byte
dim e as byte
dim f as byte
DIM NUMB_BORR AS BYTE
DIM INDICE AS BYTE
DIM TEMP AS BYTE
ADCON1 = 7 "todo digital
SPBRG = 129 " Set baud rate to 9600
TXSTA = %00100100 "brg high speed=1
"TXSTA = %00100000 "brg low speed=0
rcsta= %11011000 "SOLO 9 bits solo va a interrupcion
INTCON = %01000000
PIE1.5=1 "interrupcion al recibir-
OPTION_REG.3=1 "tiner asignado al wdt
OPTION_REG.0=1
OPTION_REG.1=1
OPTION_REG.2=1
"CONFIGURACION ENTRADAS Y SALIDAS
trisa=0
trisb=%00010001
trisc=%10000000
trisd=%11000000
trise=0 "led placa principal trise.1
"TRISD.6=1 "datos lector
"TRISD.7=1 "clock lector
"trisd.2=0 "rele
"trise=0 "led placa principal trise.1"
"TRISC.5=0 "BUZZER
"trisd.4=0 "led lector
"trisd.3=0"apertura puerta continua
"trisb.6=0 "activacion salida datos(DE sn75als180)
ON INTERRUPT GOTO My_Int
"INCIALIZACION DE VARIABLES
rele=0
buzz=0
code_ok=0
dato0=0
dato1=0
dato2=0
dato3=0
dato4=0
dato5=0
dato6=0
dato7=0
comando=0
int=0
ind=0
I_laz=0
llamada=0
marcadas=0
ledlect=0
activ=0 "CAMBIAR A =0!!!!!!!!!!
puert=0
abier=0
INDICE=0
TEMP=0
lamp1=1
delayms 500
lamp1=0
i1=0
i=0
activ=0
dato22=0
dato11=0
int=0
SECURE=1
Edata 0
NUMB_BORR=EREAD 0
for i=1 to NUMB_BORR
BORR=EREAD i
delayms 10
"Hserout[dec BORR,13]
next i
MAIN:
dato0=0
dato1=0
dato2=0
dato3=0
dato4=0
dato5=0
dato6=0
dato7=0
call comienzo
if CODE_OK.0=1 then
if dato6=63 and dato5=156 and dato4=213 and dato0=0 then
IF SECURE=1 THEN
dato22=dato2
dato11=dato1
SECURE=0
ELSE
SECURE=1
IF dato22=dato2 AND dato11=dato1 THEN
goto check
ENDIF
ENDIF
endif
endif
goto MAIN
nada:
if NUMB_BORR=0 then salteto
FOR I=1 TO NUMB_BORR
IF BORR=ID_CARD THEN MAIN
NEXT I
salteto:
gosub beep
goto MAIN
beep:
e=ind+1
f=ind+2
B[ind ]= ID_CARD & %0000000011111111 "byte bajo
B[e]=(ID_CARD & %1111111100000000) >>8 "byte alto
D= B[ind] ^ B[e]
B[f]=D
marcadas= marcadas + 1
ind=ind+3
ledlect=1
IF marcadas=35 then marcadas=0:ind=0
buzz=1
for i=1 to 80
delayms 1
next i
buzz=0
for i=1 to 150
delayms 1
next i
if abier=1 then salto
ledlect=0
salto:for i=1 to 200
delayms 1
next i
rele=1
for i=1 to 150
delayms 1
next i
rele=0
return
asm
comienzo
Clrwdt
CLRF CODE_OK
MOVLW 64
MOVWF BITCONT
NUEVO_BIT
BCF STATUS,RP0
BCF STATUS,RP1
AHI Clrwdt
ENDASM
if int=1 then analizar
ASM
btfsc PORTD,7 ;salta si es cero
goto AHI
AHI1 Clrwdt
ENDASM
if int=1 then analizar
ASM
btfss PORTD,7 ;salta si es uno , transicion!!!
goto AHI1
BCF STATUS,RP0
BCF STATUS,RP1
Clrwdt
movlw 25
movwf arg1
call delay
BTFSC PORTD,6 ;SALTA SI EL BIT 1 ES 0
BCF STATUS,C
BTFSS PORTD,6 ;SALTA SI EL BIT 1 ES 1
BSF STATUS,C
Clrwdt
movlw 80
movwf arg1
call delay
call DESPLAZAR
DECFSZ BITCONT
GOTO NUEVO_BIT
CALL HEADER
Clrwdt
return
DESPLAZAR
;---DESPLAZAMIENTO DE TODOS LOS DATOS INCLUIDOS LOS CARRIES---
Clrwdt
RLF DATO0,F ;HACE SHIFT 1 BIT A LA IZQUIERDA
RLF DATO1,F ;HACE SHIFT 1 BIT A LA IZQUIERDA
RLF DATO2,F ;HACE SHIFT 1 BIT A LA IZQUIERDA
RLF DATO3,F ;HACE SHIFT 1 BIT A LA IZQUIERDA
RLF DATO4,F ;HACE SHIFT 1 BIT A LA IZQUIERDA
RLF DATO5,F ;HACE SHIFT 1 BIT A LA IZQUIERDA
RLF DATO6,F ;HACE SHIFT 1 BIT A LA IZQUIERDA
RLF DATO7,F ;HACE SHIFT 1 BIT A LA IZQUIERDA
Clrwdt
RETURN
;*****************************************************************
; ENCUENTRA EL HEADER DE LA TARJETA
;*****************************************************************
HEADER
CLRF CONT
;---DESPLAZAMIENTO DE TODOS LOS DATOS INCLUIDOS LOS CARRIES---
ROTAR_HEADER
Clrwdt
BTFSS DATO0,0
BCF STATUS,C
BTFSC DATO0,0
BSF STATUS,C
RRF DATO7,F ;HACE SHIFT 1 BIT A LA DERECHA
RRF DATO6,F ;HACE SHIFT 1 BIT A LA DERECHA
RRF DATO5,F ;HACE SHIFT 1 BIT A LA DERECHA
RRF DATO4,F ;HACE SHIFT 1 BIT A LA DERECHA
Clrwdt
RRF DATO3,F ;HACE SHIFT 1 BIT A LA DERECHA
RRF DATO2,F ;HACE SHIFT 1 BIT A LA DERECHA
RRF DATO1,F ;HACE SHIFT 1 BIT A LA DERECHA
RRF DATO0,F ;HACE SHIFT 1 BIT A LA DERECHA
Clrwdt
INCF CONT,F
MOVLW 128 ;AGRAEGADO
XORWF CONT,W ;AGRAEGADO
BTFSC STATUS,Z
GOTO MAL_HEADER
MOVlW 255
XORWF DATO7,W
BTFSS STATUS,Z ;SALTA SI _DATO7=11100110
GOTO ROTAR_HEADER
MOVlW 63 ;HEADER DE ATMEL HEADER1,W
XORWF DATO6,W
BTFSS STATUS,Z
GOTO ROTAR_HEADER
BSF CODE_OK,0 ;AGREGADOOOOOOO!!!!!!!!!!!!!
MAL_HEADER
Clrwdt
RETURN
delay
IR
Clrwdt
DECFSZ ARG1,F
goto IR
return
endasm
analizar:
int=0
if comando=1 then RECIBIR
IF llamada=1 THEN "LLAMADA A ENVIO DE DATOS
llamada=0
if marcadas = 0 then "NO TENGO NADA PARA MANDAR :MANDO "NNN"
PIE1.5=0
gosub activado
for i=1 to 3
B1="N"
gosub putchar
next i
delayms 20
gosub desactivado
PIE1.5=1
else
goto enviar "hay marcadas VOY A RUTINA ENVIO DE DATOS
endif
endif
GOTO main "VUELVO AL LAZO PRINCIPAL
RECIBIR: PIE1.5=0 "interrupcion al recibir-
comando=0
A=0
i1=0
i=0
charin2: i1=i1+1
if i1=65500 then i1=0:i=i+1
IF PIR1.5 = 0 Then
if i=10 then lamp1=1: delayms 500: lamp1=0:PIE1.5=1: goto main
goto charin2
else
B2=RCREG
B3[A]=B2
A=A+1
if A=4 then
goto seguir1
else
i1=0
i=0
goto charin2
endif
endif
seguir1: gosub activado
DELAYMS 2
D=B3[0]^B3[1]^B3[2]
IF D=B3[3] then
B1="B" "se recibio bien la info
gosub putchar
I_laz=0
delayms 10
gosub desactivado
gosub acciones
else
I_laz=I_laz + 1
if I_laz>5 then
I_laz=0
B1="F" "se recibio mal la info mas de 5 veces ,manda info de falla de la red
gosub putchar
for i=1 to 10
delayms 1
next i
gosub desactivado
else
B1="M"
gosub putchar
endif
ENDIF
delayms 100
PIE1.5=1
goto main
Enviar:
gosub activado
RCSTA = %10010000 "RECIBO 8 BITS PARA VER SI RECIBI BIEN LA TRANSMISION
for i2=1 to marcadas
indice2=(3 * i2) - 1
indice1=indice2-2
again:bien=0
mal=0
falla=0
if marca > 3 then "si mas de 4 veces recibo falla sigo con el otro dato
lamp1=0
mal=0
falla=0
bien=0
marca=0
goto seguir
endif
for i=indice1 to indice2
B1=B
gosub putchar
delayms 3
next i
for i1=0 to 1000
delayms 1
if bien=1 then seguir"buzz=1:delayms 5:buzz=0 : goto seguir
if mal=1 then
lamp1=1
delayms 100
lamp1=0
marca=marca+1 "marca:cantidad de veces que recibo falla
goto again
endif
next i1
seguir:
next i2
seguir2:
rcsta= %11011000 "VUELBO A RECIBIR 9 BITS
marca=0
marcadas=0
ind=0
gosub desactivado
goto main
PutChar: If PIR1.4 = 0 Then PutChar " Wait for transmit register empty
TXREG = B1 " Send character to transmit register
Return
desactivado: "alta impedancia,puedo recibir no puedo enviar
activ=0
return
activado:
activ=1
return
check:
if dato3=103 and dato2= 212 and dato1= 34 then ID_CARD=1: GOTO nada
if dato3=188 and dato2=130 and dato1=250 then ID_CARD=2: GOTO nada
if dato3=161 and dato2=230 and dato1=186 then ID_CARD=3: GOTO nada
if dato3=194 and dato2=175 and dato1=226 then ID_CARD=4:GOTO nada
if dato3=196 and dato2=59 and dato1=110 then ID_CARD=5:GOTO nada
if dato3=211 and dato2=169 and dato1=54 then ID_CARD=6:GOTO nada
if dato3=203 and dato2=66 and dato1=226 then ID_CARD=7:GOTO nada
if dato3=110 and dato2=152 and dato1=134 then ID_CARD=8:GOTO nada
if dato3=162 and dato2=152 and dato1=86 then ID_CARD=9:GOTO nada
if dato3=109 and dato2=104 and dato1=190 then ID_CARD=10:GOTO nada
if dato3=110 and dato2=14 and dato1=86 then ID_CARD=11:GOTO nada
if dato3=167 and dato2=111 and dato1=26 then ID_CARD=12:GOTO nada
if dato3=182 and dato2=253 and dato1=138 then ID_CARD=13:GOTO nada
if dato3=26 and dato2=202 and dato1=238 then ID_CARD=14:GOTO nada
if dato3=127 and dato2=169 and dato1=38 then ID_CARD=15:GOTO nada
if dato3=4 and dato2=170 and dato1=202 then ID_CARD=16:GOTO nada
if dato3=124 and dato2=105 and dato1=214 then ID_CARD=17:GOTO nada
if dato3=109 and dato2=159 and dato1=250 then ID_CARD=18:GOTO nada
if dato3=13 and dato2=114 and dato1=42 then ID_CARD=19:GOTO nada
if dato3=211 and dato2=214 and dato1=150 then ID_CARD=20:GOTO nada
if dato3=28 and dato2=155 and dato1=190 then ID_CARD=21:GOTO nada
if dato3=196 and dato2=131 and dato1=134 then ID_CARD=22:GOTO nada
if dato3=171 and dato2=119 and dato1=6 then ID_CARD=23:GOTO nada
if dato3=4 and dato2=171 and dato1=70 then ID_CARD=24:GOTO nada
if dato3=193 and dato2=159 and dato1=46 then ID_CARD=25:GOTO nada
if dato3=124 and dato2=18 and dato1=22 then ID_CARD=26:GOTO nada
if dato3=118 and dato2=64 and dato1=70 then ID_CARD=27:GOTO nada
if dato3=117 and dato2=215 and dato1=218 then ID_CARD=28:GOTO nada
if dato3=194 and dato2=212 and dato1=230 then ID_CARD=29:GOTO nada
if dato3=176 and dato2=20 and dato1=246 then ID_CARD=30:GOTO nada
if dato3=97 and dato2=61 and dato1=154 then ID_CARD=31:GOTO nada
if dato3=176 and dato2=182 and dato1=142 then ID_CARD=32:GOTO nada
if dato3=185 and dato2=174 and dato1=94 then ID_CARD=33:GOTO nada
if dato3=124 and dato2=224 and dato1=190 then ID_CARD=34:GOTO nada
if dato3=25 and dato2=111 and dato1=46 then ID_CARD=35:GOTO nada
if dato3=16 and dato2=61 and dato1=122 then ID_CARD=36:GOTO nada
if dato3=181 and dato2=36 and dato1=242 then ID_CARD=37:GOTO nada
if dato3=97 and dato2=112 and dato1=102 then ID_CARD=38:GOTO nada
if dato3=8 and dato2=203 and dato1=70 then ID_CARD=39:GOTO nada
if dato3=16 and dato2=205 and dato1=130 then ID_CARD=40:GOTO nada
if dato3=203 and dato2=132 and dato1=38 then ID_CARD=41:GOTO nada
if dato3=179 and dato2=62 and dato1=110 then ID_CARD=42:GOTO nada
if dato3=118 and dato2=11 and dato1=138 then ID_CARD=43:GOTO nada
if dato3=7 and dato2=183 and dato1=38 then ID_CARD=44:GOTO nada
if dato3=21 and dato2=106 and dato1=30 then ID_CARD=45:GOTO nada
if dato3=176 and dato2=182 and dato1=74 then ID_CARD=46:GOTO nada
if dato3=176 and dato2=112 and dato1=74 then ID_CARD=47:GOTO nada
if dato3=174 and dato2=108 and dato1=18 then ID_CARD=48:GOTO nada
if dato3=19 and dato2=15 and dato1=230 then ID_CARD=49:GOTO nada
if dato3=179 and dato2=182 and dato1=138 then ID_CARD=50:GOTO nada
if dato3=16 and dato2=118 and dato1=114 then ID_CARD=51:GOTO nada
if dato3=171 and dato2=18 and dato1=242 then ID_CARD=52:GOTO nada
if dato3=22 and dato2=16 and dato1=146 then ID_CARD=53:GOTO nada
if dato3=167 and dato2=208 and dato1=78 then ID_CARD=54:GOTO nada
if dato3=124 and dato2=157 and dato1=138 then ID_CARD=55:GOTO nada
if dato3=11 and dato2= 10 and dato1=254 then ID_CARD=56:GOTO nada
if dato3=213 and dato2=211 and dato1=118 then ID_CARD=57:GOTO nada
if dato3=97 and dato2=209 and dato1=194 then ID_CARD=58:GOTO nada
if dato3=112 and dato2=178 and dato1=38 then ID_CARD=59:GOTO nada
if dato3=31 and dato2=118 and dato1=170 then ID_CARD=60:GOTO nada
if dato3=124 and dato2=13 and dato1=106 then ID_CARD=61:GOTO nada
if dato3=13 and dato2=253 and dato1=114 then ID_CARD=62:GOTO nada
if dato3=97 and dato2=211 and dato1=146 then ID_CARD=63:GOTO nada
if dato3=117 and dato2=68 and dato1= 34 then ID_CARD=64:GOTO nada
if dato3=194 and dato2=202 and dato1=210 then ID_CARD=65:GOTO nada
if dato3=100 and dato2=231 and dato1=246 then ID_CARD=66:GOTO nada
if dato3=19 and dato2=21 and dato1=118 then ID_CARD=67:GOTO nada
if dato3=205 and dato2=23 and dato1=22 then ID_CARD=68:GOTO nada
if dato3=97 and dato2= 22 and dato1=78 then ID_CARD=69:GOTO nada
if dato3=173 and dato2=129 and dato1=194 then ID_CARD=70:GOTO nada
if dato3=103 and dato2=227 and dato1=86 then ID_CARD=71:GOTO nada
if dato3=115 and dato2=118 and dato1=182 then ID_CARD=72:GOTO nada
if dato3=176 and dato2=180 and dato1=26 then ID_CARD=73:GOTO nada
if dato3=14 and dato2= 228 and dato1=58 then ID_CARD=74:GOTO nada
if dato3=206 and dato2=228 and dato1=242 then ID_CARD=75:GOTO nada
if dato3=181 and dato2=104 and dato1=130 then ID_CARD=76:GOTO nada
if dato3=211 and dato2=178 and dato1= 238 then ID_CARD=77:GOTO nada
if dato3=174 and dato2=57 and dato1=234 then ID_CARD=78:GOTO nada
if dato3=118 and dato2=69 and dato1=170 then ID_CARD=79:GOTO nada
if dato3=176 and dato2=135 and dato1=14 then ID_CARD=80:GOTO nada
if dato3=188 and dato2=114 and dato1=2 then ID_CARD=81:GOTO nada
if dato3=179 and dato2=214 and dato1=86 then ID_CARD=82:GOTO nada
if dato3=98 and dato2=213 and dato1=98 then ID_CARD=83:GOTO nada
if dato3=179 and dato2=57 and dato1=210 then ID_CARD=84:GOTO nada
if dato3=124 and dato2=130 and dato1=246 then ID_CARD=85:GOTO nada
if dato3=193 and dato2=114 and dato1=62 then ID_CARD=86:GOTO nada
if dato3=11 and dato2=182 and dato1=118 then ID_CARD=87:GOTO nada
if dato3=115 and dato2=93 and dato1=98 then ID_CARD=88:GOTO nada
if dato3=173 and dato2=17 and dato1=230 then ID_CARD=89:GOTO nada
if dato3=196 and dato2=172 and dato1=50 then ID_CARD=90:GOTO nada
if dato3=173 and dato2=183 and dato1=254 then ID_CARD=91:GOTO nada
if dato3=26 and dato2=157 and dato1=70 then ID_CARD=92:GOTO nada
if dato3=100 and dato2=181 and dato1=118 then ID_CARD=93:GOTO nada
if dato3=19 and dato2=204 and dato1=10 then ID_CARD=94:GOTO nada
if dato3=214 and dato2=178 and dato1=230 then ID_CARD=95:GOTO nada
if dato3=8 and dato2=92 and dato1=26 then ID_CARD=96:GOTO nada
if dato3=104 and dato2=214 and dato1=170 then ID_CARD=97:GOTO nada
if dato3=168 and dato2=119 and dato1=198 then ID_CARD=98:GOTO nada
if dato3=211 and dato2=134 and dato1=130 then ID_CARD=99:GOTO nada
if dato3=191 and dato2=107 and dato1=74 then ID_CARD=100:GOTO nada
goto main
acciones:
If B3[0]=1 then "abre la puerta
abier=1
rele=1
delayms 150
rele=0
puert=1
ledlect=1
endif
if B3[0]=2 then "funcionamento normal
abier=0
puert=0
ledlect=0
endif
if B3[0]=3 then "BAJA TARJETA
NUMB_BORR=EREAD 0
NUMB_BORR=NUMB_BORR+1
EWRITE 0,[NUMB_BORR]
EWRITE NUMB_BORR,[B3[1]]
BORR[NUMB_BORR]=B3[1]
lamp1=1
DELAYMS 1000
lamp1=0
endif
"ALTA TARJETA
IF B3[0]=4 THEN
"BUSCO INDICE
FOR INDICE=1 TO NUMB_BORR
IF BORR[INDICE]=B3[1] THEN BORRO
NEXT INDICE
GOTO SALIR
BORRO:
IF INDICE=NUMB_BORR THEN SALTIN
FOR I1=INDICE TO NUMB_BORR-1
BORR[I1]=BORR[I1+1]
TEMP=EREAD I1+1
DELAYMS 10
EWRITE I1,[TEMP]
DELAYMS 5
NEXT I1
SALTIN:NUMB_BORR=NUMB_BORR-1
EWRITE 0,[NUMB_BORR]
Lamp1=1
DELAYMS 1000
lamp1=0
ENDIF
SALIR:
return
DISABLE " Disable interrupts in the handler
My_Int:
mal=0
bien=0
int=1
comando=0
llamada=0
lamp1=1
DELAYMS 5
lamp1=0
charin: If PIR1.5 = 0 Then charin "recibo contestacion=prendo lamp
B2=RCREG
IF B2="M" THEN "recibo contestación mala recepcion
mal=1
ENDIF
IF B2="B" THEN "recibo contestación ok recepción
bien=1
ENDIF
IF B2="E" THEN "recibo comandos(LO USO PARA stand by,CADA PIC TIENE SU LETRA)
lamp1=1
delayms 10
lamp1=0
comando=1
endif
IF B2="H" THEN "recibo llamada para enviar datos
lamp1=1
delayms 10
lamp1=0
llamada=1
endif
IF RCSTA.2=1 then B2=RCREG "falla=1: "verifico error de framing"stop bit =0!!salta!!
IF RCSTA.1=1 THEN RCSTA.4=0 : RCSTA.4=1 "borro overflow "verifico overflow
terminar:
RESUME " Return to main program
ENABLE " Enable interrupts after the handler
END