Subversion Repositories svnkaklik

Rev

Rev 410 | Details | Compare with Previous | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
CCS PCW C Compiler, Version 3.110, 15448
2
 
3
               Filename: d:\@kaklik\programy\pic_c\ps2mys\main.LST
4
 
5
               ROM used: 273 (27%)
6
                         Largest free fragment is 751
7
               RAM used: 9 (13%) at main() level
8
                         12 (18%) worst case
9
               Stack:    1 locations
10
 
11
*
12
0000:  MOVLW  00
13
0001:  MOVWF  0A
14
0002:  GOTO   0D1
15
0003:  NOP
16
....................  #include "D:\@Kaklik\programy\PIC_C\PS2mys\main.h" 
17
....................  #include <16F84.h> 
18
....................  //////// Standard Header file for the PIC16F84 device ////////////////  
19
.................... #device PIC16F84  
20
.................... #list  
21
....................  
22
.................... #use delay(clock=4000000)  
23
0004:  MOVLW  16
24
0005:  MOVWF  04
25
0006:  MOVF   00,W
26
0007:  BTFSC  03.2
27
0008:  GOTO   018
28
0009:  MOVLW  01
29
000A:  MOVWF  0D
30
000B:  CLRF   0C
31
000C:  DECFSZ 0C,F
32
000D:  GOTO   00C
33
000E:  DECFSZ 0D,F
34
000F:  GOTO   00B
35
0010:  MOVLW  4A
36
0011:  MOVWF  0C
37
0012:  DECFSZ 0C,F
38
0013:  GOTO   012
39
0014:  NOP
40
0015:  NOP
41
0016:  DECFSZ 00,F
42
0017:  GOTO   009
43
0018:  GOTO   0DB (RETURN)
44
.................... #fuses XT,NOWDT  
45
....................   
46
.................... #DEFINE  DATA     PIN_B0      // musi byt definovan kanal DATA  
47
.................... #DEFINE  CLK      PIN_B1      // a taky hodiny CLK  
48
....................   
49
.................... #define  PRVNI    1000                 // nastaveni prodlevy pred zacatkem vysilani bajtu  
50
.................... #define  DRUHY    2  
51
.................... #define  TRETI    DRUHY  
52
....................   
53
.................... // prikazy  
54
.................... #define  RESET                   0xFF  
55
.................... #define  ENABLE_DATA_REPORTING   0xF4  
56
.................... #define  READ_DATA               0xEB  
57
.................... #define  STATUS_REQUEST          0xE9  
58
.................... #define  SET_REMOTE_MODE         0xF0  
59
.................... #define  SET_STREAM_MODE         0xEA  
60
.................... #define  GET_DEVICE_ID           0xF2  
61
....................   
62
.................... #DEFINE  LED_yellow      PIN_A3  
63
.................... #DEFINE  LED_red  PIN_A2  
64
....................   
65
.................... #DEFINE  BLIK     120            // doba rozsviceni led  
66
....................  
67
.................... #include "PS2.c" 
68
....................  // Modul pro komunikaci s Mysi  
69
....................   
70
.................... void send(byte command)  
71
.................... {  
72
....................    int n;  
73
0019:  CLRF   17
74
....................    int parity=0;  
75
....................   
76
....................    //Request-to-send  
77
....................    output_float(DATA);  
78
001A:  BSF    03.5
79
001B:  BSF    06.0
80
....................    output_low(CLK);  
81
001C:  BCF    06.1
82
001D:  BCF    03.5
83
001E:  BCF    06.1
84
....................    delay_us(100);  
85
001F:  MOVLW  21
86
0020:  MOVWF  0C
87
0021:  DECFSZ 0C,F
88
0022:  GOTO   021
89
....................    // start bit  
90
....................    output_low(DATA);  
91
0023:  BSF    03.5
92
0024:  BCF    06.0
93
0025:  BCF    03.5
94
0026:  BCF    06.0
95
....................    delay_us(20);  
96
0027:  MOVLW  06
97
0028:  MOVWF  0C
98
0029:  DECFSZ 0C,F
99
002A:  GOTO   029
100
002B:  NOP
101
....................    while(!input(CLK));  
102
002C:  BSF    03.5
103
002D:  BSF    06.1
104
002E:  BCF    03.5
105
002F:  BTFSS  06.1
106
0030:  GOTO   02C
107
....................    // 8 bitu  
108
....................    for(n=0; n<8; n++)  
109
0031:  CLRF   16
110
0032:  MOVF   16,W
111
0033:  SUBLW  07
112
0034:  BTFSS  03.0
113
0035:  GOTO   052
114
....................    {  
115
....................       while(input(CLK));  
116
0036:  BSF    03.5
117
0037:  BSF    06.1
118
0038:  BCF    03.5
119
0039:  BTFSC  06.1
120
003A:  GOTO   036
121
....................       output_bit(DATA, command & 1);  
122
003B:  MOVF   15,W
123
003C:  ANDLW  01
124
003D:  XORLW  00
125
003E:  BTFSS  03.2
126
003F:  GOTO   042
127
0040:  BCF    06.0
128
0041:  GOTO   043
129
0042:  BSF    06.0
130
0043:  BSF    03.5
131
0044:  BCF    06.0
132
....................       parity += command & 1;  
133
0045:  BCF    03.5
134
0046:  MOVF   15,W
135
0047:  ANDLW  01
136
0048:  ADDWF  17,F
137
....................       command>>=1;  
138
0049:  BCF    03.0
139
004A:  RRF    15,F
140
....................       while(!input(CLK));  
141
004B:  BSF    03.5
142
004C:  BSF    06.1
143
004D:  BCF    03.5
144
004E:  BTFSS  06.1
145
004F:  GOTO   04B
146
....................    };  
147
0050:  INCF   16,F
148
0051:  GOTO   032
149
....................    // parita  
150
....................    while(input(CLK));  
151
0052:  BSF    03.5
152
0053:  BSF    06.1
153
0054:  BCF    03.5
154
0055:  BTFSC  06.1
155
0056:  GOTO   052
156
....................    output_bit(DATA, ~parity & 1);  
157
0057:  MOVF   17,W
158
0058:  XORLW  FF
159
0059:  ANDLW  01
160
005A:  XORLW  00
161
005B:  BTFSS  03.2
162
005C:  GOTO   05F
163
005D:  BCF    06.0
164
005E:  GOTO   060
165
005F:  BSF    06.0
166
0060:  BSF    03.5
167
0061:  BCF    06.0
168
....................    while(!input(CLK));  
169
0062:  BSF    06.1
170
0063:  BCF    03.5
171
0064:  BTFSC  06.1
172
0065:  GOTO   068
173
0066:  BSF    03.5
174
0067:  GOTO   062
175
0068:  GOTO   069
176
....................    // stop bit  
177
....................    while(input(CLK));  
178
0069:  BSF    03.5
179
006A:  BSF    06.1
180
006B:  BCF    03.5
181
006C:  BTFSC  06.1
182
006D:  GOTO   069
183
....................    output_bit(DATA, 1);  
184
006E:  BSF    06.0
185
006F:  BSF    03.5
186
0070:  BCF    06.0
187
....................    while(!input(CLK));  
188
0071:  BSF    06.1
189
0072:  BCF    03.5
190
0073:  BTFSC  06.1
191
0074:  GOTO   077
192
0075:  BSF    03.5
193
0076:  GOTO   071
194
0077:  GOTO   078
195
....................    output_float(DATA);  
196
0078:  BSF    03.5
197
0079:  BSF    06.0
198
007A:  BCF    03.5
199
007B:  GOTO   0E0 (RETURN)
200
.................... }  
201
....................   
202
....................   
203
.................... int8 read_byte(int8 const poradi)  
204
.................... {  
205
.................... int8 bajt;  
206
.................... int8 i;  
207
....................   
208
....................    // cekani na komunikacni klid  
209
....................    for (i=0; i<poradi; i++)  
210
007C:  CLRF   16
211
007D:  SUBWF  16,W
212
007E:  BTFSC  03.0
213
007F:  GOTO   08D
214
....................    {  
215
....................       if (!input(CLK) || !input(DATA)) i=0;  
216
0080:  BSF    03.5
217
0081:  BSF    06.1
218
0082:  BCF    03.5
219
0083:  BTFSS  06.1
220
0084:  GOTO   08A
221
0085:  BSF    03.5
222
0086:  BSF    06.0
223
0087:  BCF    03.5
224
0088:  BTFSC  06.0
225
0089:  GOTO   08B
226
008A:  CLRF   16
227
....................    };  
228
008B:  INCF   16,F
229
008C:  GOTO   07D
230
....................   
231
....................    // cekani na startbit  
232
....................    while(input(CLK) || input(DATA));  
233
008D:  BSF    03.5
234
008E:  BSF    06.1
235
008F:  BCF    03.5
236
0090:  BTFSC  06.1
237
0091:  GOTO   08D
238
0092:  BSF    03.5
239
0093:  BSF    06.0
240
0094:  BCF    03.5
241
0095:  BTFSC  06.0
242
0096:  GOTO   08D
243
....................    while(!input(CLK));  
244
0097:  BSF    03.5
245
0098:  BSF    06.1
246
0099:  BCF    03.5
247
009A:  BTFSS  06.1
248
009B:  GOTO   097
249
....................   
250
....................    bajt = 0;  
251
009C:  CLRF   15
252
....................    for(i=0; i<8; i++)  
253
009D:  CLRF   16
254
009E:  MOVF   16,W
255
009F:  SUBLW  07
256
00A0:  BTFSS  03.0
257
00A1:  GOTO   0BD
258
....................    {  
259
....................       while(input(CLK));   // ceka na nulu hodin  
260
00A2:  BSF    03.5
261
00A3:  BSF    06.1
262
00A4:  BCF    03.5
263
00A5:  BTFSC  06.1
264
00A6:  GOTO   0A2
265
....................   
266
....................       bajt >>= 1;  
267
00A7:  BCF    03.0
268
00A8:  RRF    15,F
269
....................       bajt |= input(DATA) << 7;  
270
00A9:  BSF    03.5
271
00AA:  BSF    06.0
272
00AB:  MOVLW  00
273
00AC:  BCF    03.5
274
00AD:  BTFSC  06.0
275
00AE:  MOVLW  01
276
00AF:  MOVWF  0C
277
00B0:  RRF    0C,W
278
00B1:  CLRF   0C
279
00B2:  BTFSC  03.0
280
00B3:  BSF    0C.7
281
00B4:  MOVF   0C,W
282
00B5:  IORWF  15,F
283
....................   
284
....................       while(!input(CLK));  // ceka na jednicku hodin  
285
00B6:  BSF    03.5
286
00B7:  BSF    06.1
287
00B8:  BCF    03.5
288
00B9:  BTFSS  06.1
289
00BA:  GOTO   0B6
290
....................    };  
291
00BB:  INCF   16,F
292
00BC:  GOTO   09E
293
....................    return (bajt);  
294
00BD:  MOVF   15,W
295
00BE:  MOVWF  0D
296
00BF:  RETLW  00
297
.................... }  
298
....................   
299
....................   
300
.................... /*void read_all_byte(int8*st,*nd,*rd)           // precte 3 bajty  
301
.................... {  
302
.................... int8 i;  
303
....................   
304
.................... //   *st=read_byte(1st);  
305
....................   
306
....................    // cekani na startbit  
307
....................    while(input(CLK) || input(DATA));  
308
....................    while(!input(CLK));  
309
....................    *nd = 0;  
310
....................    for(i=0; i<8; i++)  
311
....................    {  
312
....................       while(input(CLK));   // ceka na nulu hodin  
313
....................   
314
....................       *nd |= input(DATA) << 7;  
315
....................       *nd >>= 1;  
316
....................   
317
....................       while(!input(CLK));  // ceka na jednicku hodin  
318
....................    };  
319
....................   
320
....................    // cekani na startbit  
321
....................    while(input(CLK) || input(DATA));  
322
....................    while(!input(CLK));  
323
....................    *rd = 0;  
324
....................    for(i=0; i<8; i++)  
325
....................    {  
326
....................       while(input(CLK));   // ceka na nulu hodin  
327
....................   
328
....................       *rd |= input(DATA) << 7;  
329
....................       *rd >>= 1;  
330
....................   
331
....................       while(!input(CLK));  // ceka na jednicku hodin  
332
....................    };  
333
.................... }*/  
334
....................  
335
....................   
336
.................... #define SIGN_X 4  
337
....................   
338
.................... void trigger()  
339
.................... {  
340
....................    output_high(PIN_A0);  
341
00C0:  BSF    03.5
342
00C1:  BCF    05.0
343
00C2:  BCF    03.5
344
00C3:  BSF    05.0
345
....................    output_low(PIN_A0);  
346
00C4:  BSF    03.5
347
00C5:  BCF    05.0
348
00C6:  BCF    03.5
349
00C7:  BCF    05.0
350
....................    delay_us(100);  
351
00C8:  MOVLW  21
352
00C9:  MOVWF  0C
353
00CA:  DECFSZ 0C,F
354
00CB:  GOTO   0CA
355
....................    output_high(PIN_A0);  
356
00CC:  BSF    03.5
357
00CD:  BCF    05.0
358
00CE:  BCF    03.5
359
00CF:  BSF    05.0
360
00D0:  GOTO   0FC (RETURN)
361
.................... }  
362
....................   
363
.................... void flash_red()                             // blikne ledkou  
364
.................... {  
365
....................    output_high(LED_red);  
366
....................    Delay_ms(BLIK);  
367
....................    output_low(LED_red);  
368
.................... }  
369
....................   
370
.................... void flash_yellow()                             // blikne ledkou  
371
.................... {  
372
....................    output_high(LED_yellow);  
373
....................    Delay_ms(BLIK);  
374
....................    output_low(LED_yellow);  
375
.................... }  
376
....................   
377
.................... void main()  
378
.................... {  
379
.................... int8 X,y,tl=0;  
380
*
381
00D4:  CLRF   11
382
00D5:  CLRF   14
383
.................... int8 X_old,y_old,tl_old=0;  
384
*
385
00D1:  CLRF   04
386
00D2:  MOVLW  1F
387
00D3:  ANDWF  03,F
388
....................   
389
....................    Delay_ms(500);  
390
*
391
00D6:  MOVLW  02
392
00D7:  MOVWF  15
393
00D8:  MOVLW  FA
394
00D9:  MOVWF  16
395
00DA:  GOTO   004
396
00DB:  DECFSZ 15,F
397
00DC:  GOTO   0D8
398
....................    send(ENABLE_DATA_REPORTING);  
399
00DD:  MOVLW  F4
400
00DE:  MOVWF  15
401
00DF:  GOTO   019
402
....................   
403
....................    while(true)  
404
....................    {  
405
....................       tl = read_byte(PRVNI);  
406
00E0:  MOVLW  E8
407
00E1:  BSF    03.5
408
00E2:  BSF    03.6
409
00E3:  MOVWF  7F
410
00E4:  BCF    03.5
411
00E5:  BCF    03.6
412
00E6:  CALL   07C
413
00E7:  MOVF   0D,W
414
00E8:  MOVWF  11
415
....................        x = read_byte(DRUHY);  
416
00E9:  MOVLW  02
417
00EA:  BSF    03.5
418
00EB:  BSF    03.6
419
00EC:  MOVWF  7F
420
00ED:  BCF    03.5
421
00EE:  BCF    03.6
422
00EF:  CALL   07C
423
00F0:  MOVF   0D,W
424
00F1:  MOVWF  0F
425
....................        y = read_byte(TRETI);  
426
00F2:  MOVLW  02
427
00F3:  BSF    03.5
428
00F4:  BSF    03.6
429
00F5:  MOVWF  7F
430
00F6:  BCF    03.5
431
00F7:  BCF    03.6
432
00F8:  CALL   07C
433
00F9:  MOVF   0D,W
434
00FA:  MOVWF  10
435
....................       trigger();  
436
00FB:  GOTO   0C0
437
....................   
438
....................   
439
....................       if (bit_test(tl, SIGN_X))  
440
00FC:  BTFSS  11.4
441
00FD:  GOTO   107
442
....................       {  
443
....................          output_high(LED_red);  
444
00FE:  BSF    03.5
445
00FF:  BCF    05.2
446
0100:  BCF    03.5
447
0101:  BSF    05.2
448
....................          output_low(LED_yellow);  
449
0102:  BSF    03.5
450
0103:  BCF    05.3
451
0104:  BCF    03.5
452
0105:  BCF    05.3
453
....................       }  
454
....................       else  
455
0106:  GOTO   10F
456
....................       {  
457
....................          output_high(LED_yellow);  
458
0107:  BSF    03.5
459
0108:  BCF    05.3
460
0109:  BCF    03.5
461
010A:  BSF    05.3
462
....................          output_low(LED_red);  
463
010B:  BSF    03.5
464
010C:  BCF    05.2
465
010D:  BCF    03.5
466
010E:  BCF    05.2
467
....................       }  
468
....................    }  
469
010F:  GOTO   0E0
470
.................... }  
471
....................   
472
0110:  SLEEP
473
....................   
474
....................