Go to most recent revision | Blame | Last modification | View Log | Download
#include 16C84.INC
#define debug 0
Dozadu EQU 1
Dopredu EQU 2
;--------------------------------------
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
;--- Macro na spozdeni 1ms az 255ms ---
Delay macro _ms
movlw _ms
movwf CT2
call Delay1ms
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 3
Delay 50
call Vlevo
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
;--- Spozdeni v nasobcich 10ms ----
Delay1ms:
IF debug == 0
movlw 100 ; 1 ms
movwf CT1
call Delay10us
decfsz CT2, f
goto Delay1ms
ENDIF
return
;--- Spozdeni v nasobcich 10us ----
Delay10us: ; Prodleva (CT1 * 10us)+3us
nop
nop
nop
nop
nop
nop
nop
decfsz CT1, f
goto Delay10us
return
;-----------------------------------
Vpravo:
bsf PORTB, 0
Delay 250
Delay 50
bcf PORTB, 0
return
;---------------------------------------
Celemvzad:
call Vpravo
bsf PORTB, 0
Delay 125
bcf PORTB, 0
return
;---------------------------------------
Vlevo:
call Vpravo
bsf PORTB, 0
Delay 250
Delay 75
bcf PORTB, 0
return
;----------------------------
; Definice promenych
;----------------------------
cblock
CT1
CT2
CT3
endc
end