Subversion Repositories svnkaklik

Rev

Blame | Last modification | View Log | Download

;;
;;      include         DELAY.INC
;;
;;DELAY5        ; Delka spozdeni v nasobcich 5us
;;DELAY1        ; Delka spozdeni v nasobcich 1ms
;;
;
; Procedury pro generovani spozdeni SW prostredky
;
; Include 16C84.INC pro definici zakladnich registru

__DELAY__:      ; Priznak modulu DELAY

        ifndef  __16C84__
        error   "Include file 16C84.INC"
        endif

        ifndef  DELAY5
        cblock
                DELAY5
        endc
        endif

        ifndef  DELAY1
        cblock
                DELAY1
        endc
        endif

;-----------------------
;
; Short Delay - 6 az 1281 us 'a 5us --> 1+5*DELAY5 [us]
;
;-----------------------
;
; Vstup:        DELAY5          pozadovane spozdeni v 5us jednotkach
; Nici:         DELAY5

del_0:
        goto    $+1                     ; Cyklus je 5us
delay5us:
        decfsz  DELAY5
        goto    del_0
        return                  ; Cas pro call a return je take zapocten

;-----------------------
;
; Jednorazove spozdeni 10ms
;
;-----------------------
;
; Nici:         W, DELAY1, DELAY5

delay10ms:
        movlw   10
        movwf   DELAY1

;-----------------------
;
; Long Delay - 1 az 256 ms 'a 1ms --> 1000*DELAY1 + 3 [us]
;
;-----------------------
;
; Vstup:        DELAY1          pozadovane spozdeni v 1ms
; Znici:        W, DELAY5, DELAY1

delay1ms:
        movlw   (1000 / 5 ) - 2 ; 1us
        movwf   DELAY5          ; 1us
        goto    $+1             ; 2us
        goto    $+1             ; 2us
        call    delay5us        ; 198 * 5 + 1 = 991us
        decfsz  DELAY1          ; 1/2us
        goto    delay1ms        ; 2us
        return                  ; 2us