Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
#include 16C84.INC
2
 
3
#define debug	0
4
 
5
Dozadu	EQU	1
6
Dopredu	EQU	2
7
;--------------------------------------
8
Vpred_ON macro
9
	bsf	PORTA, Dopredu
10
	endm
11
;--------------------------------------
12
Vpred_OFF macro
13
	bcf	PORTA, Dopredu
14
	Delay	50
15
	bsf	PORTA, Dozadu		;zabrzdi
16
	Delay	125
17
	bcf	PORTA, Dozadu
18
	endm
19
 
20
;--- Macro na spozdeni 1ms az 255ms ---
21
Delay	macro	_ms
22
	movlw	_ms	
23
	movwf	CT2
24
	call	Delay1ms	
25
	endm
26
;--------------------------------------
27
Vpred   macro	d
28
	movlw	d		; x dlazdicek
29
	movwf	CT3
30
	call	Vpred0
31
	endm
32
 
33
;--------------------------------------
34
	org	0
35
 
36
	goto	Start
37
	;--------------------
38
	org	4
39
	;--------------------
40
Start:
41
	page1
42
	movlw 	00000000B	; inicializace citace a prescaleru
43
	movwf	TMR0
44
	movlw 	00000000B	; konfigurace preruseni
45
	movwf	INTCON
46
 
47
	page1
48
	movlw	11110001B	; nastaveni portu na vstup nebo vystup
49
	movwf	PORTA		; 1=vstup 0=vystup
50
	movlw	11110110B
51
	movwf	PORTB
52
 
53
	bsf	TMR0, 7		; vypni pull-up na PORTB (OPTION registr)
54
 
55
	page0
56
 
57
	clrw			; vynulovani portu
58
	movwf	PORTA
59
	movwf	PORTB
60
 
61
	bsf	PORTB, 3	; Pridrz napajeni
62
 
63
	bsf	PORTA, 3	; Rozsvit LED
64
	Delay	250
65
	bcf	PORTA, 3	; Zhasni LED
66
 
67
MainLoop:
68
	Vpred	3
69
	Delay	50
70
	call	Vlevo
71
	bcf	PORTB, 3	; Vypni napajeni
72
Smycka:
73
	goto	Smycka
74
	;----------------  
75
 
76
;--- Popojede o n dlazdic vpred ---
77
Vpred0:
78
	Vpred_ON
79
	Delay	175
80
	bsf	PORTB, 0
81
	Delay	15
82
	bcf	PORTB, 0
83
	Delay	175
84
	Vpred_OFF
85
	Delay	50
86
	decfsz	CT3, f
87
	goto	Vpred0
88
	return
89
 
90
;--- Spozdeni v nasobcich 10ms ----
91
Delay1ms:
92
 IF debug == 0
93
	movlw	100		; 1 ms
94
	movwf	CT1
95
	call	Delay10us
96
 
97
	decfsz	CT2, f
98
	goto	Delay1ms
99
 ENDIF
100
	return
101
 
102
;--- Spozdeni v nasobcich 10us ----
103
Delay10us:			; Prodleva (CT1 * 10us)+3us
104
	nop	
105
	nop
106
	nop
107
	nop
108
	nop
109
	nop
110
	nop
111
	decfsz	CT1, f
112
	goto	Delay10us
113
	return
114
;-----------------------------------
115
Vpravo:
116
	bsf	PORTB, 0
117
	Delay	250
118
	Delay	50 
119
	bcf	PORTB, 0
120
	return
121
 
122
;---------------------------------------
123
Celemvzad:
124
	call	Vpravo
125
	bsf	PORTB, 0			
126
	Delay	125				
127
	bcf	PORTB, 0			
128
	return
129
;---------------------------------------
130
Vlevo:
131
	call	Vpravo
132
	bsf	PORTB, 0		
133
	Delay	250
134
	Delay	75		
135
	bcf	PORTB, 0	
136
	return
137
;----------------------------
138
; Definice promenych
139
;----------------------------
140
	cblock	
141
 
142
	CT1
143
	CT2
144
	CT3
145
	endc
146
 
147
	end