Buenas, estoy realizando un programa en mikrobasic con un pic 16f628a, lo que hace basicamente es leer los codigos RC5 de un control y segun el numero precionado activa la salida correspondiente en el puerto a, el programa funciona bien, cunado presiono la tecla 1, enciende el LED colocado en el puerto A bit 0, pero cuando presiono el numero 2 enciende el LED puerto A bit 1 y se apaga el bit 0, ya no se que hacer, les copio parte del codigo para que me puedan dar una mano. El programa simulado en Proteus funciona de maravillas.
Main:
TRISA = %00000000
PORTb.0 = 0
TRISB = 0
PORTB = 0xFF
TRISB = %00000001
porta = 0x00
'Reset de variables
Inicio_Bit_1=0
Inicio_Bit_2=0
Toggle_Bit=0
Comando=0
Sistema=0
Control=0
n3=0
t=0
a=0
d = 0
j = 0
Lcd_Init() ' Initialize Lcd
Lcd_Cmd(_LCD_CLEAR) ' Clear display
Lcd_Cmd(_LCD_CURSOR_OFF) ' Cursor off
lcd_out(2,2,"RC5")
while true
Inicio:
BD1 = 0
WHILE PORTb.0 = 1
Comando=0
Sistema=0
Control=0
WEND
BD1 = 0
WHILE (PORTb.0= 0) And (BD1 < Glitch)
INC(BD1)
WEND
IF BD1 > Glitch THEN
delay_ms(1)
goto inicio
End if
ComandoAnt = Comando 'Guarda los valores anteriores por si hay algun error
SistemaAnt = Sistema
Delay_us(200) '200us de respiro para el procesamiento del primer dato
Inicio_Bit_1.0=Bit_IR 'Bits de inicio
Inicio_Bit_2.0=Bit_IR
Sistema.4=Bit_IR 'Bits de Sistema
Sistema.3=Bit_IR
Sistema.2=Bit_IR
Sistema.1=Bit_IR
Sistema.0=Bit_IR
Comando.5=Bit_IR 'Bits de comando
Comando.4=Bit_IR
Comando.3=Bit_IR
Comando.2=Bit_IR
Comando.1=Bit_IR
Comando.0=Bit_IR
'Bit de Toggle
Toggle_Bit = Toggle_Bit xor 1
select case comando ' en esta variable se muestra correctamente la tecla presionada
case 1
porta.0 = toggle_bit
case 2
porta.1 = toggle_bit
case 3
porta.2 = toggle_bit
case 4
porta.3 = toggle_bit
end select
'Presentamos la informacion de comando recibida
bytetostr(comando,txt)
LCD_out(1,1,"com: "+txt)
bytetostr(a,txt)
lcd_out(2,1,"sistema: "+txt)
bytetostr(tecla,txt)
lcd_out(1,9,"tcl: "+txt)
Delay_ms(10)
wend
End.
muchas gracias