
; *******************************************************************
; PICkit 2 Lesson 2 - "Blink"
;
; First lesson showed how to make an LED turn on,
; Now we'll look at how to make it blink.  Delay loops are necessary
; to slow down the on and off commands so they are visible to humans.
; *******************************************************************
#include <p18cxxx.inc>
     config CPUDIV = NOCLKDIV
     config USBDIV = OFF
     config FOSC   = HS
     config PLLEN  = ON
     config FCMEN  = OFF
     config IESO   = OFF
     config PWRTEN = OFF
     config BOREN  = OFF
     config BORV   = 30
     config WDTEN  = OFF
     config WDTPS  = 32768
     config MCLRE  = ON 
     config HFOFST = OFF
     config STVREN = ON
     config LVP    = OFF
     config XINST  = OFF
     config BBSIZ  = OFF
     config CP0    = OFF
     config CP1    = OFF
     config CPB    = OFF
     config WRT0   = OFF
     config WRT1   = OFF
     config WRTB   = OFF
     config WRTC   = OFF
     config EBTR0  = OFF
     config EBTR1  = OFF
     config EBTRB  = OFF 

     cblock 0
;--- három változót definálunk a késleltetéshez
szamlalo1
szamlalo2
szamlalo3
     endc

     org 0
;--- A főprogram 
main:     bcf    LATC,0        ;RC0 kezdetben = '0'
          bcf    TRISC,0       ;RC0 legyen kimenet
ciklus:   call   delay         ;várunk valameddig...
          btg    LATC,0        ;RC0 bit billegtetése 
          bra    ciklus        ;Végtelen ciklus

;--- A késleltető szubrutin  ~ 260 msec        
delay:    movlw  0x10
          movwf  szamlalo3
          clrf   szamlalo2
          clrf   szamlalo1
loop:     decfsz szamlalo1     ;1.számláló fogyasztása
          bra    loop
          decfsz szamlalo2     ;2.számláló fogyasztása
          bra    loop
          decfsz szamlalo3     ;3.számláló fogyasztása
          bra    loop
          return
     end
      
