Subversion Repositories svnkaklik

Rev

Blame | Last modification | View Log | Download

#include 16C84.INC

#define debug   0

#include delaymac.inc

Dozadu  EQU     1
Dopredu EQU     2

;--- Macro na spozdeni 1ms az 255ms ---
Delay   macro   ms
        Delay1ms ms
;       movlw   ms
;       movwf   _delay_ms
;       call    _delay1ms
        endm
;--------------------------------------
Vpred_ON macro
        bsf     PORTA, Dopredu
        endm
;--------------------------------------
Vpred_OFF macro
        bcf     PORTA, Dopredu
        Delay   50
        bsf     PORTA, Dozadu           ;zabrzdi
        Delay   125
        bcf     PORTA, Dozadu
        endm
;--------------------------------------
Vpred   macro   d
        movlw   d               ; x dlazdicek
        movwf   CT3
        call    Vpred0
        endm

;--------------------------------------
        org     0

        goto    Start
        ;--------------------
        org     4
        ;--------------------
Start:
        page1
        movlw   00000000B       ; inicializace citace a prescaleru
        movwf   TMR0
        movlw   00000000B       ; konfigurace preruseni
        movwf   INTCON

        page1
        movlw   11110001B       ; nastaveni portu na vstup nebo vystup
        movwf   PORTA           ; 1=vstup 0=vystup
        movlw   11110110B
        movwf   PORTB

        bsf     TMR0, 7         ; vypni pull-up na PORTB (OPTION registr)

        page0

        clrw                    ; vynulovani portu
        movwf   PORTA
        movwf   PORTB

        bsf     PORTB, 3        ; Pridrz napajeni

        bsf     PORTA, 3        ; Rozsvit LED
        Delay   250
        bcf     PORTA, 3        ; Zhasni LED

MainLoop:
        Vpred   12
        Delay   200
        call    Celemvzat
        Delay   50
        Vpred   8
        Delay   50
        call    Vlevo
        Vpred   8
        Delay   50
        Vpred   1
        Delay   50
        call    Vpravo
        Delay   50
        Vpred   8
        Delay   50
        call    Vlevo
        Delay   50
        Vpred   3
        call    Celemvzat
        bcf     PORTB, 3        ; Vypni napajeni
Smycka:
        goto    Smycka
        ;----------------  

;--- Popojede o n dlazdic vpred ---
Vpred0:
        Vpred_ON
        Delay   175
        bsf     PORTB, 0
        Delay   15
        bcf     PORTB, 0
        Delay   175
        Vpred_OFF
        Delay   50
        decfsz  CT3, f
        goto    Vpred0
        return

Vpravo:
        bsf     PORTB, 0
        Delay   250
        Delay   60
        bcf     PORTB, 0
        return

;---------------------------------------
Celemvzat:
        call    Vpravo
        bsf     PORTB, 0                        
        Delay   125                             
        bcf     PORTB, 0                        
        return
;---------------------------------------
Vlevo:
        call    Vpravo
        bsf     PORTB, 0                
        Delay   250
        Delay   70              
        bcf     PORTB, 0        
        return

#include delayfce.inc

;----------------------------
; Definice promenych 
;----------------------------
        cblock
        CT3             ;Citac poctu dlazdicek
        endc

        end