Step 6 of 11
Enable interrupts (GIE and TMR0IE)
Goal
Turn on the enable chain: clear TMR0IF, set TMR0IE, GIE, and start the timer.
Without GIE = 1 no ISR runs — it is the global master switch.
Course sequence (Timer0):
1. BCF INTCON, TMR0IF — clear stale flag
2. BSF INTCON, TMR0IE — enable source
3. BSF INTCON, GIE — enable globally
4. BSF T0CON, TMR0ON — counter starts
Main loop (bucle) can stay empty: the ISR will drive the LED in step 8.
Follow these steps
- In
inicio, after both CALLs, add the four lines from the highlighted block. - Order: clear TMR0IF before enabling interrupts.
- Build with no errors.
- If you load in Proteus now, the LED will not blink yet — ISR body is missing.
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
ORG 0x0008
GOTO isr_alta
ORG 0x0018
GOTO isr_baja
CBLOCK 0x20
temp_w
temp_status
ENDC
init_gpio:
BCF TRISB, 0
BCF LATB, 0
RETURN
init_timer0:
MOVLW B'00000111'
MOVWF T0CON
MOVLW B'01100111'
MOVWF TMR0H
MOVLW B'01101010'
MOVWF TMR0L
RETURN
isr_alta:
RETFIE
isr_baja:
RETFIE
inicio:
CALL init_gpio
CALL init_timer0
BCF INTCON, TMR0IF ; limpia bandera antes de habilitar
BSF INTCON, TMR0IE ; habilita interrupcion Timer0
BSF INTCON, GIE ; maestro global
BSF T0CON, TMR0ON ; arranca el timer
bucle:
GOTO bucle
END
What you add in this step
BCF INTCON, TMR0IF
BSF INTCON, TMR0IE
BSF INTCON, GIE
BSF T0CON, TMR0ON
Checklist before you continue
- I added the four enable lines in inicio.
- I know GIE is required for any ISR.
- Builds with no errors.