Ir al contenido

Paso 8 de 11

LAT: encender el LED (primera prueba)

Objetivo

Agregar LAT en inicio, generar .HEX y ver el LED encendido en simulacion.

Las salidas se escriben en LATB, no en PORTB. Agregamos BCF LATB,0 (apagado inicial) y BSF LATB,0 (encendido de prueba).

Este es tu primer resultado visible. Si el LED no enciende aqui, no sigas — revisa TRIS, esquema y config bits.

  1. En inicio, despues de CALL init_gpio, agrega las dos lineas LAT del bloque resaltado.
  2. Compila y localiza el .HEX en la carpeta del proyecto (dist o build).
  3. Proteus: doble clic al PIC → Program File → selecciona el .HEX.
  4. Play en Proteus: el LED debe quedar encendido. Si no, vuelve al paso 5 o 6.
						        LIST    P=18F4550
        #include <P18F4550.INC>

        CONFIG  FOSC = HS
        CONFIG  WDT = OFF
        CONFIG  LVP = OFF
        CONFIG  PBADEN = OFF

        ORG     0x0000
        GOTO    inicio

init_gpio:
        BCF     TRISB, 0
        BSF     TRISB, 1
        RETURN

inicio:
        CALL    init_gpio
        BCF     LATB, 0       ; LED apagado al arrancar
        BSF     LATB, 0       ; prueba: enciende LED en Proteus
bucle:
        GOTO    bucle

        END
					
						inicio:
        CALL    init_gpio
        BCF     LATB, 0       ; LED apagado al arrancar
        BSF     LATB, 0       ; prueba: enciende LED
					
  • Agregue BCF/BSF LATB,0 en inicio.
  • Compilé y cargué el HEX en Proteus (o placa).
  • **Vi el LED encendido** — confirmado con mis ojos o la simulacion.