Skip to content

Step 8 of 11

LAT: turn on the LED (first test)

Goal

Add LAT in inicio, generate .HEX, and see the LED on in simulation.

Outputs are written to LATB, not PORTB. We add BCF LATB,0 (initial off) and BSF LATB,0 (test on).

This is your first visible result. If the LED does not light here, stop — check TRIS, schematic, and config bits.

  1. In inicio, after CALL init_gpio, add the two LAT lines from the highlighted block.
  2. Build and find the .HEX in the project folder (dist or build).
  3. Proteus: double-click PIC → Program File → select the .HEX.
  4. Run Proteus: LED must stay on. If not, go back to step 5 or 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
					
  • I added BCF/BSF LATB,0 in inicio.
  • I built and loaded the HEX in Proteus (or board).
  • **I saw the LED on** — confirmed in simulation or hardware.