Subversion Repositories svnkaklik

Rev

Go to most recent revision | Details | Last modification | View Log

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