Rev Author Line No. Line
3632 jacho 1 CCS PCM C Compiler, Version 4.106, 47914 27-4-14 20:11
2  
3 Filename: D:\Honza\MLAB\Modules\HumanInterfaces\LCD2L4P02A\SW\PIC\PIC16F887\main.lst
4  
5 ROM used: 669 words (8%)
6 Largest free fragment is 2048
7 RAM used: 9 (2%) at main() level
8 22 (6%) worst case
9 Stack: 5 locations
10  
11 *
12 0000: MOVLW 01
13 0001: MOVWF 0A
14 0002: GOTO 1E5
15 0003: NOP
16 .................... #include "main.h"
17 .................... #include <16F887.h>
18 .................... //////// Standard Header file for the PIC16F887 device ////////////////
19 .................... #device PIC16F887
20 .................... #list
21 ....................
22 .................... #device adc=10
23 ....................
24 .................... #FUSES NOWDT //No Watch Dog Timer
25 .................... #FUSES INTRC //Internal RC Osc
26 .................... #FUSES NOPUT //No Power Up Timer
27 .................... #FUSES MCLR //Master Clear pin enabled
28 .................... #FUSES NOPROTECT //Code not protected from reading
29 .................... #FUSES NOCPD //No EE protection
30 .................... #FUSES NOBROWNOUT //No brownout reset
31 .................... #FUSES IESO //Internal External Switch Over mode enabled
32 .................... #FUSES FCMEN //Fail-safe clock monitor enabled
33 .................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
34 .................... #FUSES NODEBUG //No Debug mode for ICD
35 .................... #FUSES NOWRT //Program memory not write protected
36 .................... #FUSES BORV40 //Brownout reset at 4.0V
37 ....................
38 .................... #use delay(clock=8000000)
39 *
40 001F: MOVLW 27
41 0020: MOVWF 04
42 0021: BCF 03.7
43 0022: MOVF 00,W
44 0023: BTFSC 03.2
45 0024: GOTO 032
46 0025: MOVLW 02
47 0026: MOVWF 78
48 0027: CLRF 77
49 0028: DECFSZ 77,F
50 0029: GOTO 028
51 002A: DECFSZ 78,F
52 002B: GOTO 027
53 002C: MOVLW 97
54 002D: MOVWF 77
55 002E: DECFSZ 77,F
56 002F: GOTO 02E
57 0030: DECFSZ 00,F
58 0031: GOTO 025
59 0032: RETURN
60 .................... #use i2c(master, sda=PIN_C4, scl=PIN_C3)
61 .................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
62 ....................
63 ....................
64 ....................
65 .................... #define LCD_ENABLE_PIN PIN_E0 ////
66 .................... #define LCD_RS_PIN PIN_E1 ////
67 .................... #define LCD_RW_PIN PIN_E2 ////
68 .................... #define LCD_DATA4 PIN_D4 ////
69 .................... #define LCD_DATA5 PIN_D5 ////
70 .................... #define LCD_DATA6 PIN_D6 ////
71 .................... #define LCD_DATA7 PIN_D7
72 .................... #include <lcd.c>
73 .................... ///////////////////////////////////////////////////////////////////////////////
74 .................... //// LCD.C ////
75 .................... //// Driver for common LCD modules ////
76 .................... //// ////
77 .................... //// lcd_init() Must be called before any other function. ////
78 .................... //// ////
79 .................... //// lcd_putc(c) Will display c on the next position of the LCD. ////
80 .................... //// \a Set cursor position to upper left ////
81 .................... //// \f Clear display, set cursor to upper left ////
82 .................... //// \n Go to start of second line ////
83 .................... //// \b Move back one position ////
84 .................... //// If LCD_EXTENDED_NEWLINE is defined, the \n character ////
85 .................... //// will erase all remanining characters on the current ////
86 .................... //// line, and move the cursor to the beginning of the next ////
87 .................... //// line. ////
88 .................... //// If LCD_EXTENDED_NEWLINE is defined, the \r character ////
89 .................... //// will move the cursor to the start of the current ////
90 .................... //// line. ////
91 .................... //// ////
92 .................... //// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) ////
93 .................... //// ////
94 .................... //// lcd_getc(x,y) Returns character at position x,y on LCD ////
95 .................... //// ////
96 .................... //// CONFIGURATION ////
97 .................... //// The LCD can be configured in one of two ways: a.) port access or ////
98 .................... //// b.) pin access. Port access requires the entire 7 bit interface ////
99 .................... //// connected to one GPIO port, and the data bits (D4:D7 of the LCD) ////
100 .................... //// connected to sequential pins on the GPIO. Pin access ////
101 .................... //// has no requirements, all 7 bits of the control interface can ////
102 .................... //// can be connected to any GPIO using several ports. ////
103 .................... //// ////
104 .................... //// To use port access, #define LCD_DATA_PORT to the SFR location of ////
105 .................... //// of the GPIO port that holds the interface, -AND- edit LCD_PIN_MAP ////
106 .................... //// of this file to configure the pin order. If you are using a ////
107 .................... //// baseline PIC (PCB), then LCD_OUTPUT_MAP and LCD_INPUT_MAP also must ////
108 .................... //// be defined. ////
109 .................... //// ////
110 .................... //// Example of port access: ////
111 .................... //// #define LCD_DATA_PORT getenv("SFR:PORTD") ////
112 .................... //// ////
113 .................... //// To use pin access, the following pins must be defined: ////
114 .................... //// LCD_ENABLE_PIN ////
115 .................... //// LCD_RS_PIN ////
116 .................... //// LCD_RW_PIN ////
117 .................... //// LCD_DATA4 ////
118 .................... //// LCD_DATA5 ////
119 .................... //// LCD_DATA6 ////
120 .................... //// LCD_DATA7 ////
121 .................... //// ////
122 .................... //// Example of pin access: ////
123 .................... //// #define LCD_ENABLE_PIN PIN_E0 ////
124 .................... //// #define LCD_RS_PIN PIN_E1 ////
125 .................... //// #define LCD_RW_PIN PIN_E2 ////
126 .................... //// #define LCD_DATA4 PIN_D4 ////
127 .................... //// #define LCD_DATA5 PIN_D5 ////
128 .................... //// #define LCD_DATA6 PIN_D6 ////
129 .................... //// #define LCD_DATA7 PIN_D7 ////
130 .................... //// ////
131 .................... ///////////////////////////////////////////////////////////////////////////////
132 .................... //// (C) Copyright 1996,2010 Custom Computer Services ////
133 .................... //// This source code may only be used by licensed users of the CCS C ////
134 .................... //// compiler. This source code may only be distributed to other ////
135 .................... //// licensed users of the CCS C compiler. No other use, reproduction ////
136 .................... //// or distribution is permitted without written permission. ////
137 .................... //// Derivative programs created using this software in object code ////
138 .................... //// form are not restricted in any way. ////
139 .................... ///////////////////////////////////////////////////////////////////////////
140 ....................
141 .................... // define the pinout.
142 .................... // only required if port access is being used.
143 .................... typedef struct
144 .................... { // This structure is overlayed
145 .................... BOOLEAN enable; // on to an I/O port to gain
146 .................... BOOLEAN rs; // access to the LCD pins.
147 .................... BOOLEAN rw; // The bits are allocated from
148 .................... BOOLEAN unused; // low order up. ENABLE will
149 .................... int data : 4; // be LSB pin of that port.
150 .................... #if defined(__PCD__) // The port used will be LCD_DATA_PORT.
151 .................... int reserved: 8;
152 .................... #endif
153 .................... } LCD_PIN_MAP;
154 ....................
155 .................... // this is to improve compatability with previous LCD drivers that accepted
156 .................... // a define labeled 'use_portb_lcd' that configured the LCD onto port B.
157 .................... #if ((defined(use_portb_lcd)) && (use_portb_lcd==TRUE))
158 .................... #define LCD_DATA_PORT getenv("SFR:PORTB")
159 .................... #endif
160 ....................
161 .................... #if defined(__PCB__)
162 .................... // these definitions only need to be modified for baseline PICs.
163 .................... // all other PICs use LCD_PIN_MAP or individual LCD_xxx pin definitions.
164 .................... /* EN, RS, RW, UNUSED, DATA */
165 .................... const LCD_PIN_MAP LCD_OUTPUT_MAP = {0, 0, 0, 0, 0};
166 .................... const LCD_PIN_MAP LCD_INPUT_MAP = {0, 0, 0, 0, 0xF};
167 .................... #endif
168 ....................
169 .................... ////////////////////// END CONFIGURATION ///////////////////////////////////
170 ....................
171 .................... #ifndef LCD_ENABLE_PIN
172 .................... #define lcd_output_enable(x) lcdlat.enable=x
173 .................... #define lcd_enable_tris() lcdtris.enable=0
174 .................... #else
175 .................... #define lcd_output_enable(x) output_bit(LCD_ENABLE_PIN, x)
176 .................... #define lcd_enable_tris() output_drive(LCD_ENABLE_PIN)
177 .................... #endif
178 ....................
179 .................... #ifndef LCD_RS_PIN
180 .................... #define lcd_output_rs(x) lcdlat.rs=x
181 .................... #define lcd_rs_tris() lcdtris.rs=0
182 .................... #else
183 .................... #define lcd_output_rs(x) output_bit(LCD_RS_PIN, x)
184 .................... #define lcd_rs_tris() output_drive(LCD_RS_PIN)
185 .................... #endif
186 ....................
187 .................... #ifndef LCD_RW_PIN
188 .................... #define lcd_output_rw(x) lcdlat.rw=x
189 .................... #define lcd_rw_tris() lcdtris.rw=0
190 .................... #else
191 .................... #define lcd_output_rw(x) output_bit(LCD_RW_PIN, x)
192 .................... #define lcd_rw_tris() output_drive(LCD_RW_PIN)
193 .................... #endif
194 ....................
195 .................... // original version of this library incorrectly labeled LCD_DATA0 as LCD_DATA4,
196 .................... // LCD_DATA1 as LCD_DATA5, and so on. this block of code makes the driver
197 .................... // compatible with any code written for the original library
198 .................... #if (defined(LCD_DATA0) && defined(LCD_DATA1) && defined(LCD_DATA2) && defined(LCD_DATA3) && !defined(LCD_DATA4) && !defined(LCD_DATA5) && !defined(LCD_DATA6) && !defined(LCD_DATA7))
199 .................... #define LCD_DATA4 LCD_DATA0
200 .................... #define LCD_DATA5 LCD_DATA1
201 .................... #define LCD_DATA6 LCD_DATA2
202 .................... #define LCD_DATA7 LCD_DATA3
203 .................... #endif
204 ....................
205 .................... #ifndef LCD_DATA4
206 .................... #ifndef LCD_DATA_PORT
207 .................... #if defined(__PCB__)
208 .................... #define LCD_DATA_PORT 0x06 //portb
209 .................... #define set_tris_lcd(x) set_tris_b(x)
210 .................... #else
211 .................... #if defined(PIN_D0)
212 .................... #define LCD_DATA_PORT getenv("SFR:PORTD") //portd
213 .................... #else
214 .................... #define LCD_DATA_PORT getenv("SFR:PORTB") //portb
215 .................... #endif
216 .................... #endif
217 .................... #endif
218 ....................
219 .................... #if defined(__PCB__)
220 .................... LCD_PIN_MAP lcd, lcdlat;
221 .................... #byte lcd = LCD_DATA_PORT
222 .................... #byte lcdlat = LCD_DATA_PORT
223 .................... #elif defined(__PCM__)
224 .................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
225 .................... #byte lcd = LCD_DATA_PORT
226 .................... #byte lcdlat = LCD_DATA_PORT
227 .................... #byte lcdtris = LCD_DATA_PORT+0x80
228 .................... #elif defined(__PCH__)
229 .................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
230 .................... #byte lcd = LCD_DATA_PORT
231 .................... #byte lcdlat = LCD_DATA_PORT+9
232 .................... #byte lcdtris = LCD_DATA_PORT+0x12
233 .................... #elif defined(__PCD__)
234 .................... LCD_PIN_MAP lcd, lcdlat, lcdtris;
235 .................... #word lcd = LCD_DATA_PORT
236 .................... #word lcdlat = LCD_DATA_PORT+2
237 .................... #word lcdtris = LCD_DATA_PORT-0x02
238 .................... #endif
239 .................... #endif //LCD_DATA4 not defined
240 ....................
241 .................... #ifndef LCD_TYPE
242 .................... #define LCD_TYPE 2 // 0=5x7, 1=5x10, 2=2 lines
243 .................... #endif
244 ....................
245 .................... #ifndef LCD_LINE_TWO
246 .................... #define LCD_LINE_TWO 0x40 // LCD RAM address for the second line
247 .................... #endif
248 ....................
249 .................... #ifndef LCD_LINE_LENGTH
250 .................... #define LCD_LINE_LENGTH 20
251 .................... #endif
252 ....................
253 .................... BYTE const LCD_INIT_STRING[4] = {0x20 | (LCD_TYPE << 2), 0xc, 1, 6};
254 .................... // These bytes need to be sent to the LCD
255 .................... // to start it up.
256 ....................
257 .................... BYTE lcd_read_nibble(void);
258 ....................
259 .................... BYTE lcd_read_byte(void)
260 .................... {
261 .................... BYTE low,high;
262 ....................
263 .................... #if defined(__PCB__)
264 .................... set_tris_lcd(LCD_INPUT_MAP);
265 .................... #else
266 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
267 .................... output_float(LCD_DATA4);
268 *
269 0098: BSF 08.4
270 .................... output_float(LCD_DATA5);
271 0099: BSF 08.5
272 .................... output_float(LCD_DATA6);
273 009A: BSF 08.6
274 .................... output_float(LCD_DATA7);
275 009B: BSF 08.7
276 .................... #else
277 .................... lcdtris.data = 0xF;
278 .................... #endif
279 .................... #endif
280 ....................
281 .................... lcd_output_rw(1);
282 009C: BCF 03.5
283 009D: BSF 09.2
284 009E: BSF 03.5
285 009F: BCF 09.2
286 .................... delay_cycles(1);
287 00A0: NOP
288 .................... lcd_output_enable(1);
289 00A1: BCF 03.5
290 00A2: BSF 09.0
291 00A3: BSF 03.5
292 00A4: BCF 09.0
293 .................... delay_cycles(1);
294 00A5: NOP
295 .................... high = lcd_read_nibble();
296 00A6: BCF 03.5
297 00A7: CALL 05F
298 00A8: MOVF 78,W
299 00A9: MOVWF 2E
300 ....................
301 .................... lcd_output_enable(0);
302 00AA: BCF 09.0
303 00AB: BSF 03.5
304 00AC: BCF 09.0
305 .................... delay_cycles(1);
306 00AD: NOP
307 .................... lcd_output_enable(1);
308 00AE: BCF 03.5
309 00AF: BSF 09.0
310 00B0: BSF 03.5
311 00B1: BCF 09.0
312 .................... delay_us(1);
313 00B2: GOTO 0B3
314 .................... low = lcd_read_nibble();
315 00B3: BCF 03.5
316 00B4: CALL 05F
317 00B5: MOVF 78,W
318 00B6: MOVWF 2D
319 ....................
320 .................... lcd_output_enable(0);
321 00B7: BCF 09.0
322 00B8: BSF 03.5
323 00B9: BCF 09.0
324 ....................
325 .................... #if defined(__PCB__)
326 .................... set_tris_lcd(LCD_OUTPUT_MAP);
327 .................... #else
328 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
329 .................... output_drive(LCD_DATA4);
330 00BA: BCF 08.4
331 .................... output_drive(LCD_DATA5);
332 00BB: BCF 08.5
333 .................... output_drive(LCD_DATA6);
334 00BC: BCF 08.6
335 .................... output_drive(LCD_DATA7);
336 00BD: BCF 08.7
337 .................... #else
338 .................... lcdtris.data = 0x0;
339 .................... #endif
340 .................... #endif
341 ....................
342 .................... return( (high<<4) | low);
343 00BE: BCF 03.5
344 00BF: SWAPF 2E,W
345 00C0: MOVWF 77
346 00C1: MOVLW F0
347 00C2: ANDWF 77,F
348 00C3: MOVF 77,W
349 00C4: IORWF 2D,W
350 00C5: MOVWF 78
351 .................... }
352 ....................
353 .................... BYTE lcd_read_nibble(void)
354 .................... {
355 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
356 *
357 005F: CLRF 2F
358 .................... BYTE n = 0x00;
359 ....................
360 .................... /* Read the data port */
361 .................... n |= input(LCD_DATA4);
362 0060: BSF 03.5
363 0061: BSF 08.4
364 0062: MOVLW 00
365 0063: BCF 03.5
366 0064: BTFSC 08.4
367 0065: MOVLW 01
368 0066: IORWF 2F,F
369 .................... n |= input(LCD_DATA5) << 1;
370 0067: BSF 03.5
371 0068: BSF 08.5
372 0069: MOVLW 00
373 006A: BCF 03.5
374 006B: BTFSC 08.5
375 006C: MOVLW 01
376 006D: MOVWF 77
377 006E: BCF 03.0
378 006F: RLF 77,F
379 0070: MOVF 77,W
380 0071: IORWF 2F,F
381 .................... n |= input(LCD_DATA6) << 2;
382 0072: BSF 03.5
383 0073: BSF 08.6
384 0074: MOVLW 00
385 0075: BCF 03.5
386 0076: BTFSC 08.6
387 0077: MOVLW 01
388 0078: MOVWF 77
389 0079: RLF 77,F
390 007A: RLF 77,F
391 007B: MOVLW FC
392 007C: ANDWF 77,F
393 007D: MOVF 77,W
394 007E: IORWF 2F,F
395 .................... n |= input(LCD_DATA7) << 3;
396 007F: BSF 03.5
397 0080: BSF 08.7
398 0081: MOVLW 00
399 0082: BCF 03.5
400 0083: BTFSC 08.7
401 0084: MOVLW 01
402 0085: MOVWF 77
403 0086: RLF 77,F
404 0087: RLF 77,F
405 0088: RLF 77,F
406 0089: MOVLW F8
407 008A: ANDWF 77,F
408 008B: MOVF 77,W
409 008C: IORWF 2F,F
410 ....................
411 .................... return(n);
412 008D: MOVF 2F,W
413 008E: MOVWF 78
414 .................... #else
415 .................... return(lcd.data);
416 .................... #endif
417 .................... }
418 008F: RETURN
419 ....................
420 .................... void lcd_send_nibble(BYTE n)
421 .................... {
422 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
423 .................... /* Write to the data port */
424 .................... output_bit(LCD_DATA4, bit_test(n, 0));
425 *
426 0033: BTFSC 2E.0
427 0034: GOTO 037
428 0035: BCF 08.4
429 0036: GOTO 038
430 0037: BSF 08.4
431 0038: BSF 03.5
432 0039: BCF 08.4
433 .................... output_bit(LCD_DATA5, bit_test(n, 1));
434 003A: BCF 03.5
435 003B: BTFSC 2E.1
436 003C: GOTO 03F
437 003D: BCF 08.5
438 003E: GOTO 040
439 003F: BSF 08.5
440 0040: BSF 03.5
441 0041: BCF 08.5
442 .................... output_bit(LCD_DATA6, bit_test(n, 2));
443 0042: BCF 03.5
444 0043: BTFSC 2E.2
445 0044: GOTO 047
446 0045: BCF 08.6
447 0046: GOTO 048
448 0047: BSF 08.6
449 0048: BSF 03.5
450 0049: BCF 08.6
451 .................... output_bit(LCD_DATA7, bit_test(n, 3));
452 004A: BCF 03.5
453 004B: BTFSC 2E.3
454 004C: GOTO 04F
455 004D: BCF 08.7
456 004E: GOTO 050
457 004F: BSF 08.7
458 0050: BSF 03.5
459 0051: BCF 08.7
460 .................... #else
461 .................... lcdlat.data = n;
462 .................... #endif
463 ....................
464 .................... delay_cycles(1);
465 0052: NOP
466 .................... lcd_output_enable(1);
467 0053: BCF 03.5
468 0054: BSF 09.0
469 0055: BSF 03.5
470 0056: BCF 09.0
471 .................... delay_us(2);
472 0057: GOTO 058
473 0058: GOTO 059
474 .................... lcd_output_enable(0);
475 0059: BCF 03.5
476 005A: BCF 09.0
477 005B: BSF 03.5
478 005C: BCF 09.0
479 .................... }
480 005D: BCF 03.5
481 005E: RETURN
482 ....................
483 .................... void lcd_send_byte(BYTE address, BYTE n)
484 .................... {
485 .................... #if defined(__PCB__)
486 .................... set_tris_lcd(LCD_OUTPUT_MAP);
487 .................... #else
488 .................... lcd_enable_tris();
489 *
490 0090: BSF 03.5
491 0091: BCF 09.0
492 .................... lcd_rs_tris();
493 0092: BCF 09.1
494 .................... lcd_rw_tris();
495 0093: BCF 09.2
496 .................... #endif
497 ....................
498 .................... lcd_output_rs(0);
499 0094: BCF 03.5
500 0095: BCF 09.1
501 0096: BSF 03.5
502 0097: BCF 09.1
503 .................... while ( bit_test(lcd_read_byte(),7) ) ;
504 *
505 00C6: MOVF 78,W
506 00C7: MOVWF 2D
507 00C8: BTFSS 2D.7
508 00C9: GOTO 0CC
509 00CA: BSF 03.5
510 00CB: GOTO 098
511 .................... lcd_output_rs(address);
512 00CC: MOVF 2B,F
513 00CD: BTFSS 03.2
514 00CE: GOTO 0D1
515 00CF: BCF 09.1
516 00D0: GOTO 0D2
517 00D1: BSF 09.1
518 00D2: BSF 03.5
519 00D3: BCF 09.1
520 .................... delay_cycles(1);
521 00D4: NOP
522 .................... lcd_output_rw(0);
523 00D5: BCF 03.5
524 00D6: BCF 09.2
525 00D7: BSF 03.5
526 00D8: BCF 09.2
527 .................... delay_cycles(1);
528 00D9: NOP
529 .................... lcd_output_enable(0);
530 00DA: BCF 03.5
531 00DB: BCF 09.0
532 00DC: BSF 03.5
533 00DD: BCF 09.0
534 .................... lcd_send_nibble(n >> 4);
535 00DE: BCF 03.5
536 00DF: SWAPF 2C,W
537 00E0: MOVWF 2D
538 00E1: MOVLW 0F
539 00E2: ANDWF 2D,F
540 00E3: MOVF 2D,W
541 00E4: MOVWF 2E
542 00E5: CALL 033
543 .................... lcd_send_nibble(n & 0xf);
544 00E6: MOVF 2C,W
545 00E7: ANDLW 0F
546 00E8: MOVWF 2D
547 00E9: MOVWF 2E
548 00EA: CALL 033
549 .................... }
550 00EB: RETURN
551 ....................
552 .................... #if defined(LCD_EXTENDED_NEWLINE)
553 .................... unsigned int8 g_LcdX, g_LcdY;
554 .................... #endif
555 ....................
556 .................... void lcd_init(void)
557 .................... {
558 .................... BYTE i;
559 ....................
560 .................... #if defined(__PCB__)
561 .................... set_tris_lcd(LCD_OUTPUT_MAP);
562 .................... #else
563 .................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))
564 .................... output_drive(LCD_DATA4);
565 00EC: BSF 03.5
566 00ED: BCF 08.4
567 .................... output_drive(LCD_DATA5);
568 00EE: BCF 08.5
569 .................... output_drive(LCD_DATA6);
570 00EF: BCF 08.6
571 .................... output_drive(LCD_DATA7);
572 00F0: BCF 08.7
573 .................... #else
574 .................... lcdtris.data = 0x0;
575 .................... #endif
576 .................... lcd_enable_tris();
577 00F1: BCF 09.0
578 .................... lcd_rs_tris();
579 00F2: BCF 09.1
580 .................... lcd_rw_tris();
581 00F3: BCF 09.2
582 .................... #endif
583 ....................
584 .................... lcd_output_rs(0);
585 00F4: BCF 03.5
586 00F5: BCF 09.1
587 00F6: BSF 03.5
588 00F7: BCF 09.1
589 .................... lcd_output_rw(0);
590 00F8: BCF 03.5
591 00F9: BCF 09.2
592 00FA: BSF 03.5
593 00FB: BCF 09.2
594 .................... lcd_output_enable(0);
595 00FC: BCF 03.5
596 00FD: BCF 09.0
597 00FE: BSF 03.5
598 00FF: BCF 09.0
599 ....................
600 .................... delay_ms(15);
601 0100: MOVLW 0F
602 0101: BCF 03.5
603 0102: MOVWF 27
604 0103: CALL 01F
605 .................... for(i=1;i<=3;++i)
606 0104: MOVLW 01
607 0105: MOVWF 23
608 0106: MOVF 23,W
609 0107: SUBLW 03
610 0108: BTFSS 03.0
611 0109: GOTO 112
612 .................... {
613 .................... lcd_send_nibble(3);
614 010A: MOVLW 03
615 010B: MOVWF 2E
616 010C: CALL 033
617 .................... delay_ms(5);
618 010D: MOVLW 05
619 010E: MOVWF 27
620 010F: CALL 01F
621 .................... }
622 0110: INCF 23,F
623 0111: GOTO 106
624 ....................
625 .................... lcd_send_nibble(2);
626 0112: MOVLW 02
627 0113: MOVWF 2E
628 0114: CALL 033
629 .................... for(i=0;i<=3;++i)
630 0115: CLRF 23
631 0116: MOVF 23,W
632 0117: SUBLW 03
633 0118: BTFSS 03.0
634 0119: GOTO 123
635 .................... lcd_send_byte(0,LCD_INIT_STRING[i]);
636 011A: MOVF 23,W
637 011B: CALL 004
638 011C: MOVWF 24
639 011D: CLRF 2B
640 011E: MOVF 24,W
641 011F: MOVWF 2C
642 0120: CALL 090
643 ....................
644 .................... #if defined(LCD_EXTENDED_NEWLINE)
645 0121: INCF 23,F
646 0122: GOTO 116
647 .................... g_LcdX = 0;
648 .................... g_LcdY = 0;
649 .................... #endif
650 .................... }
651 0123: RETURN
652 ....................
653 .................... void lcd_gotoxy(BYTE x, BYTE y)
654 .................... {
655 .................... BYTE address;
656 ....................
657 .................... if(y!=1)
658 0124: DECFSZ 28,W
659 0125: GOTO 127
660 0126: GOTO 12A
661 .................... address=LCD_LINE_TWO;
662 0127: MOVLW 40
663 0128: MOVWF 29
664 .................... else
665 0129: GOTO 12B
666 .................... address=0;
667 012A: CLRF 29
668 ....................
669 .................... address+=x-1;
670 012B: MOVLW 01
671 012C: SUBWF 27,W
672 012D: ADDWF 29,F
673 .................... lcd_send_byte(0,0x80|address);
674 012E: MOVF 29,W
675 012F: IORLW 80
676 0130: MOVWF 2A
677 0131: CLRF 2B
678 0132: MOVF 2A,W
679 0133: MOVWF 2C
680 0134: CALL 090
681 ....................
682 .................... #if defined(LCD_EXTENDED_NEWLINE)
683 .................... g_LcdX = x - 1;
684 .................... g_LcdY = y - 1;
685 .................... #endif
686 .................... }
687 0135: RETURN
688 ....................
689 .................... void lcd_putc(char c)
690 .................... {
691 .................... switch (c)
692 .................... {
693 0136: MOVF 26,W
694 0137: XORLW 07
695 0138: BTFSC 03.2
696 0139: GOTO 144
697 013A: XORLW 0B
698 013B: BTFSC 03.2
699 013C: GOTO 149
700 013D: XORLW 06
701 013E: BTFSC 03.2
702 013F: GOTO 151
703 0140: XORLW 02
704 0141: BTFSC 03.2
705 0142: GOTO 157
706 0143: GOTO 15C
707 .................... case '\a' : lcd_gotoxy(1,1); break;
708 0144: MOVLW 01
709 0145: MOVWF 27
710 0146: MOVWF 28
711 0147: CALL 124
712 0148: GOTO 162
713 ....................
714 .................... case '\f' : lcd_send_byte(0,1);
715 0149: CLRF 2B
716 014A: MOVLW 01
717 014B: MOVWF 2C
718 014C: CALL 090
719 .................... delay_ms(2);
720 014D: MOVLW 02
721 014E: MOVWF 27
722 014F: CALL 01F
723 .................... #if defined(LCD_EXTENDED_NEWLINE)
724 .................... g_LcdX = 0;
725 .................... g_LcdY = 0;
726 .................... #endif
727 .................... break;
728 0150: GOTO 162
729 ....................
730 .................... #if defined(LCD_EXTENDED_NEWLINE)
731 .................... case '\r' : lcd_gotoxy(1, g_LcdY+1); break;
732 .................... case '\n' :
733 .................... while (g_LcdX++ < LCD_LINE_LENGTH)
734 .................... {
735 .................... lcd_send_byte(1, ' ');
736 .................... }
737 .................... lcd_gotoxy(1, g_LcdY+2);
738 .................... break;
739 .................... #else
740 .................... case '\n' : lcd_gotoxy(1,2); break;
741 0151: MOVLW 01
742 0152: MOVWF 27
743 0153: MOVLW 02
744 0154: MOVWF 28
745 0155: CALL 124
746 0156: GOTO 162
747 .................... #endif
748 ....................
749 .................... case '\b' : lcd_send_byte(0,0x10); break;
750 0157: CLRF 2B
751 0158: MOVLW 10
752 0159: MOVWF 2C
753 015A: CALL 090
754 015B: GOTO 162
755 ....................
756 .................... #if defined(LCD_EXTENDED_NEWLINE)
757 .................... default :
758 .................... if (g_LcdX < LCD_LINE_LENGTH)
759 .................... {
760 .................... lcd_send_byte(1, c);
761 .................... g_LcdX++;
762 .................... }
763 .................... break;
764 .................... #else
765 .................... default : lcd_send_byte(1,c); break;
766 015C: MOVLW 01
767 015D: MOVWF 2B
768 015E: MOVF 26,W
769 015F: MOVWF 2C
770 0160: CALL 090
771 0161: GOTO 162
772 .................... #endif
773 .................... }
774 .................... }
775 0162: RETURN
776 ....................
777 .................... char lcd_getc(BYTE x, BYTE y)
778 .................... {
779 .................... char value;
780 ....................
781 .................... lcd_gotoxy(x,y);
782 .................... while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low
783 .................... lcd_output_rs(1);
784 .................... value = lcd_read_byte();
785 .................... lcd_output_rs(0);
786 ....................
787 .................... return(value);
788 .................... }
789 ....................
790 ....................
791 .................... #define BEEPER PIN_B5
792 ....................
793 .................... int beep()
794 .................... {
795 .................... unsigned int i;
796 ....................
797 .................... i=0;
798 *
799 01CC: CLRF 23
800 .................... for(i=0;i<100;i++)
801 01CD: CLRF 23
802 01CE: MOVF 23,W
803 01CF: SUBLW 63
804 01D0: BTFSS 03.0
805 01D1: GOTO 1E2
806 .................... {
807 .................... output_low(BEEPER);
808 01D2: BSF 03.5
809 01D3: BCF 06.5
810 01D4: BCF 03.5
811 01D5: BCF 06.5
812 .................... delay_ms(1);
813 01D6: MOVLW 01
814 01D7: MOVWF 27
815 01D8: CALL 01F
816 .................... output_high(BEEPER);
817 01D9: BSF 03.5
818 01DA: BCF 06.5
819 01DB: BCF 03.5
820 01DC: BSF 06.5
821 .................... delay_ms(1);
822 01DD: MOVLW 01
823 01DE: MOVWF 27
824 01DF: CALL 01F
825 .................... }
826 01E0: INCF 23,F
827 01E1: GOTO 1CE
828 .................... }
829 01E2: BCF 0A.3
830 01E3: BCF 0A.4
831 01E4: GOTO 294 (RETURN)
832 ....................
833 ....................
834 .................... void main()
835 .................... {
836 01E5: CLRF 04
837 01E6: BCF 03.7
838 01E7: MOVLW 1F
839 01E8: ANDWF 03,F
840 01E9: MOVLW 71
841 01EA: BSF 03.5
842 01EB: MOVWF 0F
843 01EC: MOVF 0F,W
844 01ED: BSF 03.6
845 01EE: BCF 07.3
846 01EF: MOVLW 0C
847 01F0: BCF 03.6
848 01F1: MOVWF 19
849 01F2: MOVLW A2
850 01F3: MOVWF 18
851 01F4: MOVLW 90
852 01F5: BCF 03.5
853 01F6: MOVWF 18
854 01F7: BSF 03.5
855 01F8: BSF 03.6
856 01F9: MOVF 09,W
857 01FA: ANDLW C0
858 01FB: MOVWF 09
859 01FC: BCF 03.6
860 01FD: BCF 1F.4
861 01FE: BCF 1F.5
862 01FF: MOVLW 00
863 0200: BSF 03.6
864 0201: MOVWF 08
865 0202: BCF 03.5
866 0203: CLRF 07
867 0204: CLRF 08
868 0205: CLRF 09
869 *
870 0209: CLRF 22
871 020A: CLRF 21
872 .................... int16 i=0;
873 ....................
874 .................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
875 020B: BSF 03.5
876 020C: BSF 03.6
877 020D: MOVF 09,W
878 020E: ANDLW C0
879 020F: MOVWF 09
880 0210: BCF 03.6
881 0211: BCF 1F.4
882 0212: BCF 1F.5
883 0213: MOVLW 00
884 0214: BSF 03.6
885 0215: MOVWF 08
886 .................... setup_adc(ADC_CLOCK_DIV_2);
887 0216: BCF 03.5
888 0217: BCF 03.6
889 0218: BCF 1F.6
890 0219: BCF 1F.7
891 021A: BSF 03.5
892 021B: BSF 1F.7
893 021C: BCF 03.5
894 021D: BSF 1F.0
895 .................... setup_spi(SPI_SS_DISABLED);
896 021E: BCF 14.5
897 021F: BCF 20.5
898 0220: MOVF 20,W
899 0221: BSF 03.5
900 0222: MOVWF 07
901 0223: BCF 03.5
902 0224: BSF 20.4
903 0225: MOVF 20,W
904 0226: BSF 03.5
905 0227: MOVWF 07
906 0228: BCF 03.5
907 0229: BCF 20.3
908 022A: MOVF 20,W
909 022B: BSF 03.5
910 022C: MOVWF 07
911 022D: MOVLW 01
912 022E: BCF 03.5
913 022F: MOVWF 14
914 0230: MOVLW 00
915 0231: BSF 03.5
916 0232: MOVWF 14
917 .................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
918 0233: MOVF 01,W
919 0234: ANDLW C7
920 0235: IORLW 08
921 0236: MOVWF 01
922 .................... setup_timer_1(T1_DISABLED);
923 0237: BCF 03.5
924 0238: CLRF 10
925 .................... setup_timer_2(T2_DISABLED,0,1);
926 0239: MOVLW 00
927 023A: MOVWF 78
928 023B: MOVWF 12
929 023C: MOVLW 00
930 023D: BSF 03.5
931 023E: MOVWF 12
932 .................... setup_ccp1(CCP_OFF);
933 023F: BCF 03.5
934 0240: BSF 20.2
935 0241: MOVF 20,W
936 0242: BSF 03.5
937 0243: MOVWF 07
938 0244: BCF 03.5
939 0245: CLRF 17
940 0246: BSF 03.5
941 0247: CLRF 1B
942 0248: CLRF 1C
943 0249: MOVLW 01
944 024A: MOVWF 1D
945 .................... setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard
946 024B: BCF 03.5
947 024C: BSF 03.6
948 024D: CLRF 07
949 024E: CLRF 08
950 024F: CLRF 09
951 .................... setup_oscillator(OSC_8MHZ);
952 0250: MOVLW 71
953 0251: BSF 03.5
954 0252: BCF 03.6
955 0253: MOVWF 0F
956 0254: MOVF 0F,W
957 ....................
958 .................... lcd_init();
959 0255: BCF 03.5
960 0256: CALL 0EC
961 .................... lcd_putc("(c) Kaklik 2013");
962 0257: MOVLW 0C
963 0258: BSF 03.6
964 0259: MOVWF 0D
965 025A: MOVLW 00
966 025B: MOVWF 0F
967 025C: BCF 03.6
968 025D: CALL 163
969 .................... lcd_gotoxy(3,2);
970 025E: MOVLW 03
971 025F: MOVWF 27
972 0260: MOVLW 02
973 0261: MOVWF 28
974 0262: CALL 124
975 .................... lcd_putc("www.mlab.cz");
976 0263: MOVLW 14
977 0264: BSF 03.6
978 0265: MOVWF 0D
979 0266: MOVLW 00
980 0267: MOVWF 0F
981 0268: BCF 03.6
982 0269: CALL 163
983 .................... Delay_ms(2000);
984 026A: MOVLW 08
985 026B: MOVWF 23
986 026C: MOVLW FA
987 026D: MOVWF 27
988 026E: CALL 01F
989 026F: DECFSZ 23,F
990 0270: GOTO 26C
991 .................... lcd_init();
992 0271: CALL 0EC
993 ....................
994 .................... while (TRUE)
995 .................... {
996 .................... lcd_gotoxy(1,1);
997 0272: MOVLW 01
998 0273: MOVWF 27
999 0274: MOVWF 28
1000 0275: CALL 124
1001 ....................
1002 .................... printf(lcd_putc,"LCD test");
1003 0276: MOVLW 1A
1004 0277: BSF 03.6
1005 0278: MOVWF 0D
1006 0279: MOVLW 00
1007 027A: MOVWF 0F
1008 027B: BCF 03.6
1009 027C: CALL 163
1010 .................... lcd_gotoxy(1,2);
1011 027D: MOVLW 01
1012 027E: MOVWF 27
1013 027F: MOVLW 02
1014 0280: MOVWF 28
1015 0281: CALL 124
1016 .................... printf(lcd_putc,"%c %x ",i,i);
1017 0282: MOVF 21,W
1018 0283: MOVWF 26
1019 0284: CALL 136
1020 0285: MOVLW 20
1021 0286: MOVWF 26
1022 0287: CALL 136
1023 0288: MOVF 21,W
1024 0289: MOVWF 23
1025 028A: MOVLW 57
1026 028B: MOVWF 24
1027 028C: GOTO 1A9
1028 028D: MOVLW 20
1029 028E: MOVWF 26
1030 028F: CALL 136
1031 .................... i++;
1032 0290: INCF 21,F
1033 0291: BTFSC 03.2
1034 0292: INCF 22,F
1035 .................... beep();
1036 0293: GOTO 1CC
1037 .................... Delay_ms(500);
1038 0294: MOVLW 02
1039 0295: MOVWF 23
1040 0296: MOVLW FA
1041 0297: MOVWF 27
1042 0298: CALL 01F
1043 0299: DECFSZ 23,F
1044 029A: GOTO 296
1045 .................... }
1046 029B: GOTO 272
1047 ....................
1048 .................... }
1049 029C: SLEEP
1050  
1051 Configuration Fuses:
1052 Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
1053 Word 2: 3FFF NOWRT BORV40