;*************************************************************************************************
;** Header Information **
;*************************************************************************************************
list p=16F628A, r=dec, w=-302
include <P16F628A.INC>
__config b'11110100100001'
;Processor is 16F628A (p)
;Radix is decimal unless otherwise noted (r)
;Errorlevel set to suppress bank select assembler messages (w)
;config word
; ___ ___ ___ ___ ___ _____
;| CP1 | CP0 | CP1 | CP0 | - | CPD | LVP |BODEN|MCLRE|FOSC2|PWRTE|WDTE |FOSC1|FOSC0|
;| 1 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 |
;Code Protection disabled (CP1-CP0)
;Data Code Protection disabled (CPD)
;Low Voltage Programming disabled (LVP)
;Brown Out Detection disabled (BODEN)
;RA5 is External Master Clear (MCLRE)
;Power Up Timer enabled (PWRTE)
;Watchdog Timer disabled (WDTE)
;Standard XT Oscillator (FOSC2-FOSC0)
;External frequency = 4MHz
;*************************************************************************************************
;** RAM Location Labels **
;*************************************************************************************************
COUNT1 EQU 0x20
COUNT2 EQU 0x21
;*************************************************************************************************
;** Port Configuration **
;*************************************************************************************************
org 0x00 ;reset vector
goto START
START bsf INTCON,GIE ;disable interrupts
movlw b'00000111' ;disable on chip comparator
movwf CMCON ;RA0-RA4 are digital I/O
banksel TRISA ;bank 1
movlw b'00000000' ;RA0-RA4 outputs
movwf TRISA
movlw b'00000000' ;RB0-RB7 outputs
movwf TRISB
banksel RCSTA ;bank 0
bcf RCSTA,SPEN ;disable serial USART
;*************************************************************************************************
;** Program Start **
;*************************************************************************************************
MAIN bsf PORTA,0 ;turn on LED on pin RA0
call DELAY ;wait
bcf PORTA,0 ;turn off LED on pin RA0
call DELAY ;wait
goto MAIN ;loop back and do it again forever
;*************************************************************************************************
;** Subroutines **
;*************************************************************************************************
DELAY movlw 0xFF ;load count 1 and count 2 with maximum value
movwf COUNT1 ;of 0xFF (decimal 255)
movwf COUNT2
decfsz COUNT1,F ;decriment register COUNT1 by a factor of 1
goto $-1 ;loop back 1 line, skip when COUNT1=0
decfsz COUNT2,F ;decriment register COUNT2 by a factor of 1
goto $-3 ;loop back 3 lines, skip when COUNT2=0
return ;return from subroutine
end