Subversion Repositories svnkaklik

Rev

Rev 318 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
318 kaklik 1
;/////////////////////////////////////////////////////////////////////////////////
2
;// Code Generator: BoostBasic Compiler - http://www.sourceboost.com
3
;// Version       : 6.70
4
;// License Type  : Pro License
5
;// Limitations   : PIC18 max code size:Unlimited, max RAM banks:Unlimited
6
;/////////////////////////////////////////////////////////////////////////////////
7
 
8
'robot
9
 
10
'#pragma DATA _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
11
 
12
 
13
#pragma DATA _CONFIG1H, _OSCS_OFF_1H & _HSPLL_OSC_1H
14
#pragma DATA _CONFIG2L, _BOR_ON_2L & _BORV_42_2L & _PWRT_ON_2L
15
#pragma DATA _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
16
#pragma DATA _CONFIG3H, _CCP2MX_OFF_3H
17
#pragma DATA _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
18
#pragma DATA _CONFIG5L, _CP0_ON_5L & _CP1_ON_5L & _CP2_ON_5L & _CP3_ON_5L
19
#pragma DATA _CONFIG5H, _CPB_ON_5H & _CPD_ON_5H
20
#pragma DATA _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L & _WRT2_OFF_6L & _WRT3_OFF_6L
21
#pragma DATA _CONFIG6H, _WRTC_ON_6H & _WRTB_ON_6H & _WRTD_OFF_6H
22
#pragma DATA _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L & _EBTR2_OFF_7L & _EBTR3_OFF_7L
23
#pragma DATA _CONFIG7H, _EBTRB_ON_7H
24
 
25
#pragma CLOCK_FREQ 40000000
26
 
27
Function receive() As Byte
28
 
29
	If ( (rcsta.OERR = 1) ) Then
30
020E  A2AB      	BTFSS gbl_rcsta,1
31
0210  D002      	BRA	label268438550
32
0216            label268438550
33
 
34
		rcsta.CREN = 0
35
0212  98AB      	BCF gbl_rcsta,4
36
 
37
        rcsta.CREN = 1
38
0214  88AB      	BSF gbl_rcsta,4
39
 
40
	End If
41
    Do While (pir1.RCIF = 0)
42
0216  AA9E      	BTFSS gbl_pir1,5
43
0218  D7FE      	BRA	label268438550
44
 
45
	Loop
46
	receive = rcreg
47
021A  50AE      	MOVF gbl_rcreg, W
48
021C  6E0A      	MOVWF CompTempVarRet489
49
 
50
 
51
End Function
52
021E  0012      	RETURN
53
 
54
 
55
Sub send(c As Byte)
56
 
57
	Do while (pir1 & (1 << TXIF)) = 0 Loop
58
0204            label268438561
59
0204  A89E      	BTFSS gbl_pir1,4
60
0206  D7FE      	BRA	label268438561
61
 
62
	txreg = c
63
0208  500A      	MOVF send_00000_arg_c, W
64
020A  6EAD      	MOVWF gbl_txreg
65
 
66
End Sub
67
020C  0012      	RETURN
68
 
69
 
70
Sub main()
71
 
72
	Dim motors As Byte
73
	Dim sensors As Byte
74
	Dim leds As Byte
75
	Dim leds1 As Byte
76
	Dim buttons As Byte
77
	Dim i As Long
78
 
79
	'NASTAVENI IO
80
	lata=0xFF
81
0220  6889      	SETF gbl_lata
82
 
83
	latb=0
84
0222  6A8A      	CLRF gbl_latb
85
 
86
	latc=0xFF
87
0224  688B      	SETF gbl_latc
88
 
89
	trisa=0xF0
90
0226  0EF0      	MOVLW 0xF0
91
0228  6E92      	MOVWF gbl_trisa
92
 
93
	trisb=0x3F
94
022A  0E3F      	MOVLW 0x3F
95
022C  6E93      	MOVWF gbl_trisb
96
 
97
	trisc=0x9F
98
022E  0E9F      	MOVLW 0x9F
99
0230  6E94      	MOVWF gbl_trisc
100
 
101
 
102
	'VYPNOUT ADC
103
	adcon1=0xC6
104
0232  0EC6      	MOVLW 0xC6
105
0234  6EC1      	MOVWF gbl_adcon1
106
 
107
	adcon0=0xC0
108
0236  0EC0      	MOVLW 0xC0
109
0238  6EC2      	MOVWF gbl_adcon0
110
 
111
 
112
	'UART 9600bps
113
	spbrg=64
114
023A  0E40      	MOVLW 0x40
115
023C  6EAF      	MOVWF gbl_spbrg
116
 
117
	txsta = txsta & ~(1 << BRGH)
118
023E  0EFB      	MOVLW 0xFB
119
0240  14AC      	ANDWF gbl_txsta, W
120
0242  6EAC      	MOVWF gbl_txsta
121
 
122
	txsta = txsta | (1 << TXEN)
123
0244  0E20      	MOVLW 0x20
124
0246  10AC      	IORWF gbl_txsta, W
125
0248  6EAC      	MOVWF gbl_txsta
126
 
127
	rcsta = rcsta | (1 << CREN)
128
024A  0E10      	MOVLW 0x10
129
024C  10AB      	IORWF gbl_rcsta, W
130
024E  6EAB      	MOVWF gbl_rcsta
131
 
132
	rcsta = rcsta | (1 << SPEN)
133
0250  0E80      	MOVLW 0x80
134
0252  10AB      	IORWF gbl_rcsta, W
135
0254  6EAB      	MOVWF gbl_rcsta
136
 
137
 
138
 
139
	leds = 0xFF
140
0256  6803      	SETF main_1_leds
141
 
142
	leds1 = 0x0F 
143
0258  0E0F      	MOVLW 0x0F
144
025A  6E04      	MOVWF main_1_leds1
145
 
146
 
147
	motors = 0x00
148
025C  6A01      	CLRF main_1_motors
149
 
150
 
151
Do while 1
152
025E            label268438595
153
 
154
 
155
		buttons = portb
156
025E  5081      	MOVF gbl_portb, W
157
0260  6E05      	MOVWF main_1_buttons
158
 
159
 
160
		If (buttons.1)=0 Then
161
0262  B205      	BTFSC main_1_buttons,1
162
0264  D022      	BRA	label268438598
163
02AA            label268438598
164
 
165
			i=0
166
0266  6A06      	CLRF main_1_i
167
0268  6A07      	CLRF main_1_i+D'1'
168
026A  6A08      	CLRF main_1_i+D'2'
169
026C  6A09      	CLRF main_1_i+D'3'
170
 
171
			leds1 = leds1 - 1
172
026E  0404      	DECF main_1_leds1, W
173
0270  6E04      	MOVWF main_1_leds1
174
 
175
			lata = leds1
176
0272  5004      	MOVF main_1_leds1, W
177
0274  6E89      	MOVWF gbl_lata
178
 
179
			Do while i <= 500000
180
0276            label268438603
181
0276  5009      	MOVF main_1_i+D'3', W
182
0278  0800      	SUBLW 0x00
183
027A  E108      	BNZ	label268438604
184
027C  5008      	MOVF main_1_i+D'2', W
185
027E  0807      	SUBLW 0x07
186
0280  E105      	BNZ	label268438604
187
0282  5007      	MOVF main_1_i+D'1', W
188
0284  08A1      	SUBLW 0xA1
189
0286  E102      	BNZ	label268438604
190
0288  5006      	MOVF main_1_i, W
191
028A  0820      	SUBLW 0x20
192
028C            label268438604
193
028C  E202      	BC	label4026532463
194
028E  AE09      	BTFSS main_1_i+D'3',7
195
0290  D008      	BRA	label268438608
196
0292            label4026532463
197
 
198
			i=i+1
199
0292  2A06      	INCF main_1_i, F
200
0294  B4D8      	BTFSC STATUS,Z
201
0296  2A07      	INCF main_1_i+D'1', F
202
0298  B4D8      	BTFSC STATUS,Z
203
029A  2A08      	INCF main_1_i+D'2', F
204
029C  B4D8      	BTFSC STATUS,Z
205
029E  2A09      	INCF main_1_i+D'3', F
206
 
207
			loop
208
02A0  D7EA      	BRA	label268438603
209
02A2            label268438608
210
 
211
			motors = motors + 0x11
212
02A2  0E11      	MOVLW 0x11
213
02A4  2401      	ADDWF main_1_motors, W
214
02A6  6E01      	MOVWF main_1_motors
215
 
216
 
217
		elseif (buttons.4)=0 Then
218
02A8  D023      	BRA	label268438619
219
02AA  B805      	BTFSC main_1_buttons,4
220
02AC  D021      	BRA	label268438619
221
02F0            label268438619
222
 
223
			i=0
224
02AE  6A06      	CLRF main_1_i
225
02B0  6A07      	CLRF main_1_i+D'1'
226
02B2  6A08      	CLRF main_1_i+D'2'
227
02B4  6A09      	CLRF main_1_i+D'3'
228
 
229
			leds1 = leds1 + 1
230
02B6  2804      	INCF main_1_leds1, W
231
02B8  6E04      	MOVWF main_1_leds1
232
 
233
			lata = leds1
234
02BA  5004      	MOVF main_1_leds1, W
235
02BC  6E89      	MOVWF gbl_lata
236
 
237
			Do while i <= 500000
238
02BE            label268438624
239
02BE  5009      	MOVF main_1_i+D'3', W
240
02C0  0800      	SUBLW 0x00
241
02C2  E108      	BNZ	label268438625
242
02C4  5008      	MOVF main_1_i+D'2', W
243
02C6  0807      	SUBLW 0x07
244
02C8  E105      	BNZ	label268438625
245
02CA  5007      	MOVF main_1_i+D'1', W
246
02CC  08A1      	SUBLW 0xA1
247
02CE  E102      	BNZ	label268438625
248
02D0  5006      	MOVF main_1_i, W
249
02D2  0820      	SUBLW 0x20
250
02D4            label268438625
251
02D4  E202      	BC	label4026532468
252
02D6  AE09      	BTFSS main_1_i+D'3',7
253
02D8  D008      	BRA	label268438629
254
02DA            label4026532468
255
 
256
			i=i+1
257
02DA  2A06      	INCF main_1_i, F
258
02DC  B4D8      	BTFSC STATUS,Z
259
02DE  2A07      	INCF main_1_i+D'1', F
260
02E0  B4D8      	BTFSC STATUS,Z
261
02E2  2A08      	INCF main_1_i+D'2', F
262
02E4  B4D8      	BTFSC STATUS,Z
263
02E6  2A09      	INCF main_1_i+D'3', F
264
 
265
			loop
266
02E8  D7EA      	BRA	label268438624
267
02EA            label268438629
268
 
269
			motors = motors - 0x11
270
02EA  0E11      	MOVLW 0x11
271
02EC  5C01      	SUBWF main_1_motors, W
272
02EE  6E01      	MOVWF main_1_motors
273
 
274
		End If
275
 
276
		leds = 0xFF
277
02F0  6803      	SETF main_1_leds
278
 
279
		sensors =0xFF 
280
02F2  6802      	SETF main_1_sensors
281
 
282
		sensors = Call receive()	'prijmi stav cidel senzoru
283
02F4  EC07F001  	CALL receive_00000
284
02F8  500A      	MOVF CompTempVarRet489, W
285
02FA  6E02      	MOVWF main_1_sensors
286
 
287
		'Bity v bajtu sensors
288
		'BIT3=LEVE SPODNI, BIT2=PRAVE SPODNI, BIT1=LEVE PREDNI, BIT0=PRAVE PREDNI
289
		'prislusny bit v nule znamena aktivni senzor
290
		If (sensors.0)=0 Then
291
02FC  B002      	BTFSC main_1_sensors,0
292
02FE  D003      	BRA	label268438643
293
0306            label268438643
294
 
295
			'pravy predni senzor aktivni
296
			'rozsvit prislusnou LED k senzoru, zatim jen v promenne
297
			leds = leds & ~(1 << 1)	'led sviti, kdyz se ji bit znuluje
298
0300  0EFD      	MOVLW 0xFD
299
0302  1403      	ANDWF main_1_leds, W
300
0304  6E03      	MOVWF main_1_leds
301
 
302
		End If
303
 
304
		If (sensors.1)=0 Then
305
0306  B202      	BTFSC main_1_sensors,1
306
0308  D003      	BRA	label268438646
307
0310            label268438646
308
 
309
			'levy predni senzor aktivni
310
			'rozsvit prislusnou LED k senzoru, zatim jen v promenne
311
			leds = leds & ~(1 << 2)	'led sviti, kdyz se ji bit znuluje
312
030A  0EFB      	MOVLW 0xFB
313
030C  1403      	ANDWF main_1_leds, W
314
030E  6E03      	MOVWF main_1_leds
315
 
316
		End If
317
 
318
		If (sensors.2)=0 Then
319
0310  B402      	BTFSC main_1_sensors,2
320
0312  D003      	BRA	label268438649
321
031A            label268438649
322
 
323
			'pravy spodni senzor aktivni
324
			'rozsvit prislusnou LED k senzoru, zatim jen v promenne
325
			leds = leds & ~(1 << 0)	'led sviti, kdyz se ji bit znuluje
326
0314  0EFE      	MOVLW 0xFE
327
0316  1403      	ANDWF main_1_leds, W
328
0318  6E03      	MOVWF main_1_leds
329
 
330
		End If
331
 
332
		If (sensors.3)=0 Then
333
031A  B602      	BTFSC main_1_sensors,3
334
031C  D003      	BRA	label268438652
335
0324            label268438652
336
 
337
			'levy spodni senzor aktivni
338
			'rozsvit prislusnou LED k senzoru, zatim jen v promenne
339
			leds = leds & ~(1 << 3)	'led sviti, kdyz se ji bit znuluje
340
031E  0EF7      	MOVLW 0xF7
341
0320  1403      	ANDWF main_1_leds, W
342
0322  6E03      	MOVWF main_1_leds
343
 
344
		End If 
345
 
346
 
347
	lata = leds
348
0324  5003      	MOVF main_1_leds, W
349
0326  6E89      	MOVWF gbl_lata
350
 
351
	call send(motors)
352
0328  5001      	MOVF main_1_motors, W
353
032A  6E0A      	MOVWF send_00000_arg_c
354
032C  EC02F001  	CALL send_00000
355
 
356
 
357
 
358
	Loop
359
0330  D796      	BRA	label268438595
360
 
361
 
362
 
363
End Sub
364
 
365
 
366
////////////////////////////////////////
367
// Code with no source :-)
368
////////////////////////////////////////
369
0200  EF99F001  	GOTO	_startup
370
 
371
 
372
0332            _startup
373
0332  EF10F001  	GOTO	main
374
 
375
300000  FEFF      	DW 0xFEFF
376
300002  FEF6      	DW 0xFEF6
377
300004  FEFF      	DW 0xFEFF
378
300006  FFFB      	DW 0xFFFB
379
300008  3FF0      	DW 0x3FF0
380
30000A  9FFF      	DW 0x9FFF
381
30000C  BFFF      	DW 0xBFFF