LIST P=16F84A
#include <P16F84A.INC>
ERRORLEVEL -302 ;suppress bank selection messages
CBLOCK 0x0C ;block of variable defenitions, starting at memory adress 0x0c
Loop1 ;The pic16F84A's RAM starts at this adress (see datasheet)
Loop2
Loop3 ;all counters for the delay loop
ENDC ;variables end
ORG 0x00 ;program entry adress
BANKSEL TRISB ;go to memory bank 1 for loading TRIS values
BCF TRISB, 0 ;clear TRISB, bit 0 -> makes PORTB bit 0 an output (for the led)
BANKSEL PORTB ;back to bank 0
MainLoop ;this part will be repeated over and over and ...
BCF PORTB, 0 ;make the led pin low (led will light)
CALL Delay ;and call the delay
BSF PORTB, 0 ;make the led pin high (led will go out)
CALL Delay ;and wait again
GOTO MainLoop ;back to beginning
Delay ;the delay routine
MOVLW 0x10
MOVWF Loop1 ;put 10h in loop1
Reload_Loop2
MOVLW 0xFF
MOVWF Loop2 ;put FFh in Loop2
Reload_Loop3
MOVLW 0xFF
MOVWF Loop3 ;put FFh in Loop3
DECFSZ Loop3, F ;subtract 1 from loop3, skip next instruction if result = 0
GOTO $-1 ;go back 1 instruction
DECFSZ Loop2, F
GOTO Reload_Loop3 ;if not 0, then reload loop3
DECFSZ Loop1, F ;if not 0, then reload loop2
GOTO Reload_Loop2
RETURN
END