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.
Follow these steps
- In
inicio, afterCALL init_gpio, add the two LAT lines from the highlighted block. - Build and find the
.HEXin the project folder (dist or build). - Proteus: double-click PIC → Program File → select the
.HEX. - Run Proteus: LED must stay on. If not, go back to step 5 or 6.
Your file so far
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
What you add in this step
inicio:
CALL init_gpio
BCF LATB, 0 ; LED apagado al arrancar
BSF LATB, 0 ; prueba: enciende LED
Checklist before you continue
- 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.