1045 |
jacho |
1 |
CCS PCM C Compiler, Version 4.106, 47914 23-3-13 19:05 |
|
|
2 |
|
|
|
3 |
Filename: C:\Users\Honza\Documents\pic\blik\main.lst |
|
|
4 |
|
|
|
5 |
ROM used: 236 words (3%) |
|
|
6 |
Largest free fragment is 2048 |
|
|
7 |
RAM used: 6 (2%) at main() level |
|
|
8 |
9 (2%) worst case |
|
|
9 |
Stack: 1 locations |
|
|
10 |
|
|
|
11 |
* |
|
|
12 |
0000: MOVLW 00 |
|
|
13 |
0001: MOVWF 0A |
|
|
14 |
0002: GOTO 066 |
|
|
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=8 |
|
|
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 |
.................... |
|
|
41 |
.................... |
|
|
42 |
.................... #define LCD_ENABLE_PIN PIN_E0 //// |
|
|
43 |
.................... #define LCD_RS_PIN PIN_E1 //// |
|
|
44 |
.................... #define LCD_RW_PIN PIN_E2 //// |
|
|
45 |
.................... #define LCD_DATA4 PIN_D4 //// |
|
|
46 |
.................... #define LCD_DATA5 PIN_D5 //// |
|
|
47 |
.................... #define LCD_DATA6 PIN_D6 //// |
|
|
48 |
.................... #define LCD_DATA7 PIN_D7 |
|
|
49 |
.................... #include <lcd.c> |
|
|
50 |
.................... /////////////////////////////////////////////////////////////////////////////// |
|
|
51 |
.................... //// LCD.C //// |
|
|
52 |
.................... //// Driver for common LCD modules //// |
|
|
53 |
.................... //// //// |
|
|
54 |
.................... //// lcd_init() Must be called before any other function. //// |
|
|
55 |
.................... //// //// |
|
|
56 |
.................... //// lcd_putc(c) Will display c on the next position of the LCD. //// |
|
|
57 |
.................... //// \a Set cursor position to upper left //// |
|
|
58 |
.................... //// \f Clear display, set cursor to upper left //// |
|
|
59 |
.................... //// \n Go to start of second line //// |
|
|
60 |
.................... //// \b Move back one position //// |
|
|
61 |
.................... //// If LCD_EXTENDED_NEWLINE is defined, the \n character //// |
|
|
62 |
.................... //// will erase all remanining characters on the current //// |
|
|
63 |
.................... //// line, and move the cursor to the beginning of the next //// |
|
|
64 |
.................... //// line. //// |
|
|
65 |
.................... //// If LCD_EXTENDED_NEWLINE is defined, the \r character //// |
|
|
66 |
.................... //// will move the cursor to the start of the current //// |
|
|
67 |
.................... //// line. //// |
|
|
68 |
.................... //// //// |
|
|
69 |
.................... //// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) //// |
|
|
70 |
.................... //// //// |
|
|
71 |
.................... //// lcd_getc(x,y) Returns character at position x,y on LCD //// |
|
|
72 |
.................... //// //// |
|
|
73 |
.................... //// CONFIGURATION //// |
|
|
74 |
.................... //// The LCD can be configured in one of two ways: a.) port access or //// |
|
|
75 |
.................... //// b.) pin access. Port access requires the entire 7 bit interface //// |
|
|
76 |
.................... //// connected to one GPIO port, and the data bits (D4:D7 of the LCD) //// |
|
|
77 |
.................... //// connected to sequential pins on the GPIO. Pin access //// |
|
|
78 |
.................... //// has no requirements, all 7 bits of the control interface can //// |
|
|
79 |
.................... //// can be connected to any GPIO using several ports. //// |
|
|
80 |
.................... //// //// |
|
|
81 |
.................... //// To use port access, #define LCD_DATA_PORT to the SFR location of //// |
|
|
82 |
.................... //// of the GPIO port that holds the interface, -AND- edit LCD_PIN_MAP //// |
|
|
83 |
.................... //// of this file to configure the pin order. If you are using a //// |
|
|
84 |
.................... //// baseline PIC (PCB), then LCD_OUTPUT_MAP and LCD_INPUT_MAP also must //// |
|
|
85 |
.................... //// be defined. //// |
|
|
86 |
.................... //// //// |
|
|
87 |
.................... //// Example of port access: //// |
|
|
88 |
.................... //// #define LCD_DATA_PORT getenv("SFR:PORTD") //// |
|
|
89 |
.................... //// //// |
|
|
90 |
.................... //// To use pin access, the following pins must be defined: //// |
|
|
91 |
.................... //// LCD_ENABLE_PIN //// |
|
|
92 |
.................... //// LCD_RS_PIN //// |
|
|
93 |
.................... //// LCD_RW_PIN //// |
|
|
94 |
.................... //// LCD_DATA4 //// |
|
|
95 |
.................... //// LCD_DATA5 //// |
|
|
96 |
.................... //// LCD_DATA6 //// |
|
|
97 |
.................... //// LCD_DATA7 //// |
|
|
98 |
.................... //// //// |
|
|
99 |
.................... //// Example of pin access: //// |
|
|
100 |
.................... //// #define LCD_ENABLE_PIN PIN_E0 //// |
|
|
101 |
.................... //// #define LCD_RS_PIN PIN_E1 //// |
|
|
102 |
.................... //// #define LCD_RW_PIN PIN_E2 //// |
|
|
103 |
.................... //// #define LCD_DATA4 PIN_D4 //// |
|
|
104 |
.................... //// #define LCD_DATA5 PIN_D5 //// |
|
|
105 |
.................... //// #define LCD_DATA6 PIN_D6 //// |
|
|
106 |
.................... //// #define LCD_DATA7 PIN_D7 //// |
|
|
107 |
.................... //// //// |
|
|
108 |
.................... /////////////////////////////////////////////////////////////////////////////// |
|
|
109 |
.................... //// (C) Copyright 1996,2010 Custom Computer Services //// |
|
|
110 |
.................... //// This source code may only be used by licensed users of the CCS C //// |
|
|
111 |
.................... //// compiler. This source code may only be distributed to other //// |
|
|
112 |
.................... //// licensed users of the CCS C compiler. No other use, reproduction //// |
|
|
113 |
.................... //// or distribution is permitted without written permission. //// |
|
|
114 |
.................... //// Derivative programs created using this software in object code //// |
|
|
115 |
.................... //// form are not restricted in any way. //// |
|
|
116 |
.................... /////////////////////////////////////////////////////////////////////////// |
|
|
117 |
.................... |
|
|
118 |
.................... // define the pinout. |
|
|
119 |
.................... // only required if port access is being used. |
|
|
120 |
.................... typedef struct |
|
|
121 |
.................... { // This structure is overlayed |
|
|
122 |
.................... BOOLEAN enable; // on to an I/O port to gain |
|
|
123 |
.................... BOOLEAN rs; // access to the LCD pins. |
|
|
124 |
.................... BOOLEAN rw; // The bits are allocated from |
|
|
125 |
.................... BOOLEAN unused; // low order up. ENABLE will |
|
|
126 |
.................... int data : 4; // be LSB pin of that port. |
|
|
127 |
.................... #if defined(__PCD__) // The port used will be LCD_DATA_PORT. |
|
|
128 |
.................... int reserved: 8; |
|
|
129 |
.................... #endif |
|
|
130 |
.................... } LCD_PIN_MAP; |
|
|
131 |
.................... |
|
|
132 |
.................... // this is to improve compatability with previous LCD drivers that accepted |
|
|
133 |
.................... // a define labeled 'use_portb_lcd' that configured the LCD onto port B. |
|
|
134 |
.................... #if ((defined(use_portb_lcd)) && (use_portb_lcd==TRUE)) |
|
|
135 |
.................... #define LCD_DATA_PORT getenv("SFR:PORTB") |
|
|
136 |
.................... #endif |
|
|
137 |
.................... |
|
|
138 |
.................... #if defined(__PCB__) |
|
|
139 |
.................... // these definitions only need to be modified for baseline PICs. |
|
|
140 |
.................... // all other PICs use LCD_PIN_MAP or individual LCD_xxx pin definitions. |
|
|
141 |
.................... /* EN, RS, RW, UNUSED, DATA */ |
|
|
142 |
.................... const LCD_PIN_MAP LCD_OUTPUT_MAP = {0, 0, 0, 0, 0}; |
|
|
143 |
.................... const LCD_PIN_MAP LCD_INPUT_MAP = {0, 0, 0, 0, 0xF}; |
|
|
144 |
.................... #endif |
|
|
145 |
.................... |
|
|
146 |
.................... ////////////////////// END CONFIGURATION /////////////////////////////////// |
|
|
147 |
.................... |
|
|
148 |
.................... #ifndef LCD_ENABLE_PIN |
|
|
149 |
.................... #define lcd_output_enable(x) lcdlat.enable=x |
|
|
150 |
.................... #define lcd_enable_tris() lcdtris.enable=0 |
|
|
151 |
.................... #else |
|
|
152 |
.................... #define lcd_output_enable(x) output_bit(LCD_ENABLE_PIN, x) |
|
|
153 |
.................... #define lcd_enable_tris() output_drive(LCD_ENABLE_PIN) |
|
|
154 |
.................... #endif |
|
|
155 |
.................... |
|
|
156 |
.................... #ifndef LCD_RS_PIN |
|
|
157 |
.................... #define lcd_output_rs(x) lcdlat.rs=x |
|
|
158 |
.................... #define lcd_rs_tris() lcdtris.rs=0 |
|
|
159 |
.................... #else |
|
|
160 |
.................... #define lcd_output_rs(x) output_bit(LCD_RS_PIN, x) |
|
|
161 |
.................... #define lcd_rs_tris() output_drive(LCD_RS_PIN) |
|
|
162 |
.................... #endif |
|
|
163 |
.................... |
|
|
164 |
.................... #ifndef LCD_RW_PIN |
|
|
165 |
.................... #define lcd_output_rw(x) lcdlat.rw=x |
|
|
166 |
.................... #define lcd_rw_tris() lcdtris.rw=0 |
|
|
167 |
.................... #else |
|
|
168 |
.................... #define lcd_output_rw(x) output_bit(LCD_RW_PIN, x) |
|
|
169 |
.................... #define lcd_rw_tris() output_drive(LCD_RW_PIN) |
|
|
170 |
.................... #endif |
|
|
171 |
.................... |
|
|
172 |
.................... // original version of this library incorrectly labeled LCD_DATA0 as LCD_DATA4, |
|
|
173 |
.................... // LCD_DATA1 as LCD_DATA5, and so on. this block of code makes the driver |
|
|
174 |
.................... // compatible with any code written for the original library |
|
|
175 |
.................... #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)) |
|
|
176 |
.................... #define LCD_DATA4 LCD_DATA0 |
|
|
177 |
.................... #define LCD_DATA5 LCD_DATA1 |
|
|
178 |
.................... #define LCD_DATA6 LCD_DATA2 |
|
|
179 |
.................... #define LCD_DATA7 LCD_DATA3 |
|
|
180 |
.................... #endif |
|
|
181 |
.................... |
|
|
182 |
.................... #ifndef LCD_DATA4 |
|
|
183 |
.................... #ifndef LCD_DATA_PORT |
|
|
184 |
.................... #if defined(__PCB__) |
|
|
185 |
.................... #define LCD_DATA_PORT 0x06 //portb |
|
|
186 |
.................... #define set_tris_lcd(x) set_tris_b(x) |
|
|
187 |
.................... #else |
|
|
188 |
.................... #if defined(PIN_D0) |
|
|
189 |
.................... #define LCD_DATA_PORT getenv("SFR:PORTD") //portd |
|
|
190 |
.................... #else |
|
|
191 |
.................... #define LCD_DATA_PORT getenv("SFR:PORTB") //portb |
|
|
192 |
.................... #endif |
|
|
193 |
.................... #endif |
|
|
194 |
.................... #endif |
|
|
195 |
.................... |
|
|
196 |
.................... #if defined(__PCB__) |
|
|
197 |
.................... LCD_PIN_MAP lcd, lcdlat; |
|
|
198 |
.................... #byte lcd = LCD_DATA_PORT |
|
|
199 |
.................... #byte lcdlat = LCD_DATA_PORT |
|
|
200 |
.................... #elif defined(__PCM__) |
|
|
201 |
.................... LCD_PIN_MAP lcd, lcdlat, lcdtris; |
|
|
202 |
.................... #byte lcd = LCD_DATA_PORT |
|
|
203 |
.................... #byte lcdlat = LCD_DATA_PORT |
|
|
204 |
.................... #byte lcdtris = LCD_DATA_PORT+0x80 |
|
|
205 |
.................... #elif defined(__PCH__) |
|
|
206 |
.................... LCD_PIN_MAP lcd, lcdlat, lcdtris; |
|
|
207 |
.................... #byte lcd = LCD_DATA_PORT |
|
|
208 |
.................... #byte lcdlat = LCD_DATA_PORT+9 |
|
|
209 |
.................... #byte lcdtris = LCD_DATA_PORT+0x12 |
|
|
210 |
.................... #elif defined(__PCD__) |
|
|
211 |
.................... LCD_PIN_MAP lcd, lcdlat, lcdtris; |
|
|
212 |
.................... #word lcd = LCD_DATA_PORT |
|
|
213 |
.................... #word lcdlat = LCD_DATA_PORT+2 |
|
|
214 |
.................... #word lcdtris = LCD_DATA_PORT-0x02 |
|
|
215 |
.................... #endif |
|
|
216 |
.................... #endif //LCD_DATA4 not defined |
|
|
217 |
.................... |
|
|
218 |
.................... #ifndef LCD_TYPE |
|
|
219 |
.................... #define LCD_TYPE 2 // 0=5x7, 1=5x10, 2=2 lines |
|
|
220 |
.................... #endif |
|
|
221 |
.................... |
|
|
222 |
.................... #ifndef LCD_LINE_TWO |
|
|
223 |
.................... #define LCD_LINE_TWO 0x40 // LCD RAM address for the second line |
|
|
224 |
.................... #endif |
|
|
225 |
.................... |
|
|
226 |
.................... #ifndef LCD_LINE_LENGTH |
|
|
227 |
.................... #define LCD_LINE_LENGTH 20 |
|
|
228 |
.................... #endif |
|
|
229 |
.................... |
|
|
230 |
.................... BYTE const LCD_INIT_STRING[4] = {0x20 | (LCD_TYPE << 2), 0xc, 1, 6}; |
|
|
231 |
.................... // These bytes need to be sent to the LCD |
|
|
232 |
.................... // to start it up. |
|
|
233 |
.................... |
|
|
234 |
.................... BYTE lcd_read_nibble(void); |
|
|
235 |
.................... |
|
|
236 |
.................... BYTE lcd_read_byte(void) |
|
|
237 |
.................... { |
|
|
238 |
.................... BYTE low,high; |
|
|
239 |
.................... |
|
|
240 |
.................... #if defined(__PCB__) |
|
|
241 |
.................... set_tris_lcd(LCD_INPUT_MAP); |
|
|
242 |
.................... #else |
|
|
243 |
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) |
|
|
244 |
.................... output_float(LCD_DATA4); |
|
|
245 |
.................... output_float(LCD_DATA5); |
|
|
246 |
.................... output_float(LCD_DATA6); |
|
|
247 |
.................... output_float(LCD_DATA7); |
|
|
248 |
.................... #else |
|
|
249 |
.................... lcdtris.data = 0xF; |
|
|
250 |
.................... #endif |
|
|
251 |
.................... #endif |
|
|
252 |
.................... |
|
|
253 |
.................... lcd_output_rw(1); |
|
|
254 |
.................... delay_cycles(1); |
|
|
255 |
.................... lcd_output_enable(1); |
|
|
256 |
.................... delay_cycles(1); |
|
|
257 |
.................... high = lcd_read_nibble(); |
|
|
258 |
.................... |
|
|
259 |
.................... lcd_output_enable(0); |
|
|
260 |
.................... delay_cycles(1); |
|
|
261 |
.................... lcd_output_enable(1); |
|
|
262 |
.................... delay_us(1); |
|
|
263 |
.................... low = lcd_read_nibble(); |
|
|
264 |
.................... |
|
|
265 |
.................... lcd_output_enable(0); |
|
|
266 |
.................... |
|
|
267 |
.................... #if defined(__PCB__) |
|
|
268 |
.................... set_tris_lcd(LCD_OUTPUT_MAP); |
|
|
269 |
.................... #else |
|
|
270 |
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) |
|
|
271 |
.................... output_drive(LCD_DATA4); |
|
|
272 |
.................... output_drive(LCD_DATA5); |
|
|
273 |
.................... output_drive(LCD_DATA6); |
|
|
274 |
.................... output_drive(LCD_DATA7); |
|
|
275 |
.................... #else |
|
|
276 |
.................... lcdtris.data = 0x0; |
|
|
277 |
.................... #endif |
|
|
278 |
.................... #endif |
|
|
279 |
.................... |
|
|
280 |
.................... return( (high<<4) | low); |
|
|
281 |
.................... } |
|
|
282 |
.................... |
|
|
283 |
.................... BYTE lcd_read_nibble(void) |
|
|
284 |
.................... { |
|
|
285 |
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) |
|
|
286 |
.................... BYTE n = 0x00; |
|
|
287 |
.................... |
|
|
288 |
.................... /* Read the data port */ |
|
|
289 |
.................... n |= input(LCD_DATA4); |
|
|
290 |
.................... n |= input(LCD_DATA5) << 1; |
|
|
291 |
.................... n |= input(LCD_DATA6) << 2; |
|
|
292 |
.................... n |= input(LCD_DATA7) << 3; |
|
|
293 |
.................... |
|
|
294 |
.................... return(n); |
|
|
295 |
.................... #else |
|
|
296 |
.................... return(lcd.data); |
|
|
297 |
.................... #endif |
|
|
298 |
.................... } |
|
|
299 |
.................... |
|
|
300 |
.................... void lcd_send_nibble(BYTE n) |
|
|
301 |
.................... { |
|
|
302 |
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) |
|
|
303 |
.................... /* Write to the data port */ |
|
|
304 |
.................... output_bit(LCD_DATA4, bit_test(n, 0)); |
|
|
305 |
.................... output_bit(LCD_DATA5, bit_test(n, 1)); |
|
|
306 |
.................... output_bit(LCD_DATA6, bit_test(n, 2)); |
|
|
307 |
.................... output_bit(LCD_DATA7, bit_test(n, 3)); |
|
|
308 |
.................... #else |
|
|
309 |
.................... lcdlat.data = n; |
|
|
310 |
.................... #endif |
|
|
311 |
.................... |
|
|
312 |
.................... delay_cycles(1); |
|
|
313 |
.................... lcd_output_enable(1); |
|
|
314 |
.................... delay_us(2); |
|
|
315 |
.................... lcd_output_enable(0); |
|
|
316 |
.................... } |
|
|
317 |
.................... |
|
|
318 |
.................... void lcd_send_byte(BYTE address, BYTE n) |
|
|
319 |
.................... { |
|
|
320 |
.................... #if defined(__PCB__) |
|
|
321 |
.................... set_tris_lcd(LCD_OUTPUT_MAP); |
|
|
322 |
.................... #else |
|
|
323 |
.................... lcd_enable_tris(); |
|
|
324 |
.................... lcd_rs_tris(); |
|
|
325 |
.................... lcd_rw_tris(); |
|
|
326 |
.................... #endif |
|
|
327 |
.................... |
|
|
328 |
.................... lcd_output_rs(0); |
|
|
329 |
.................... while ( bit_test(lcd_read_byte(),7) ) ; |
|
|
330 |
.................... lcd_output_rs(address); |
|
|
331 |
.................... delay_cycles(1); |
|
|
332 |
.................... lcd_output_rw(0); |
|
|
333 |
.................... delay_cycles(1); |
|
|
334 |
.................... lcd_output_enable(0); |
|
|
335 |
.................... lcd_send_nibble(n >> 4); |
|
|
336 |
.................... lcd_send_nibble(n & 0xf); |
|
|
337 |
.................... } |
|
|
338 |
.................... |
|
|
339 |
.................... #if defined(LCD_EXTENDED_NEWLINE) |
|
|
340 |
.................... unsigned int8 g_LcdX, g_LcdY; |
|
|
341 |
.................... #endif |
|
|
342 |
.................... |
|
|
343 |
.................... void lcd_init(void) |
|
|
344 |
.................... { |
|
|
345 |
.................... BYTE i; |
|
|
346 |
.................... |
|
|
347 |
.................... #if defined(__PCB__) |
|
|
348 |
.................... set_tris_lcd(LCD_OUTPUT_MAP); |
|
|
349 |
.................... #else |
|
|
350 |
.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) |
|
|
351 |
.................... output_drive(LCD_DATA4); |
|
|
352 |
.................... output_drive(LCD_DATA5); |
|
|
353 |
.................... output_drive(LCD_DATA6); |
|
|
354 |
.................... output_drive(LCD_DATA7); |
|
|
355 |
.................... #else |
|
|
356 |
.................... lcdtris.data = 0x0; |
|
|
357 |
.................... #endif |
|
|
358 |
.................... lcd_enable_tris(); |
|
|
359 |
.................... lcd_rs_tris(); |
|
|
360 |
.................... lcd_rw_tris(); |
|
|
361 |
.................... #endif |
|
|
362 |
.................... |
|
|
363 |
.................... lcd_output_rs(0); |
|
|
364 |
.................... lcd_output_rw(0); |
|
|
365 |
.................... lcd_output_enable(0); |
|
|
366 |
.................... |
|
|
367 |
.................... delay_ms(15); |
|
|
368 |
.................... for(i=1;i<=3;++i) |
|
|
369 |
.................... { |
|
|
370 |
.................... lcd_send_nibble(3); |
|
|
371 |
.................... delay_ms(5); |
|
|
372 |
.................... } |
|
|
373 |
.................... |
|
|
374 |
.................... lcd_send_nibble(2); |
|
|
375 |
.................... for(i=0;i<=3;++i) |
|
|
376 |
.................... lcd_send_byte(0,LCD_INIT_STRING[i]); |
|
|
377 |
.................... |
|
|
378 |
.................... #if defined(LCD_EXTENDED_NEWLINE) |
|
|
379 |
.................... g_LcdX = 0; |
|
|
380 |
.................... g_LcdY = 0; |
|
|
381 |
.................... #endif |
|
|
382 |
.................... } |
|
|
383 |
.................... |
|
|
384 |
.................... void lcd_gotoxy(BYTE x, BYTE y) |
|
|
385 |
.................... { |
|
|
386 |
.................... BYTE address; |
|
|
387 |
.................... |
|
|
388 |
.................... if(y!=1) |
|
|
389 |
.................... address=LCD_LINE_TWO; |
|
|
390 |
.................... else |
|
|
391 |
.................... address=0; |
|
|
392 |
.................... |
|
|
393 |
.................... address+=x-1; |
|
|
394 |
.................... lcd_send_byte(0,0x80|address); |
|
|
395 |
.................... |
|
|
396 |
.................... #if defined(LCD_EXTENDED_NEWLINE) |
|
|
397 |
.................... g_LcdX = x - 1; |
|
|
398 |
.................... g_LcdY = y - 1; |
|
|
399 |
.................... #endif |
|
|
400 |
.................... } |
|
|
401 |
.................... |
|
|
402 |
.................... void lcd_putc(char c) |
|
|
403 |
.................... { |
|
|
404 |
.................... switch (c) |
|
|
405 |
.................... { |
|
|
406 |
.................... case '\a' : lcd_gotoxy(1,1); break; |
|
|
407 |
.................... |
|
|
408 |
.................... case '\f' : lcd_send_byte(0,1); |
|
|
409 |
.................... delay_ms(2); |
|
|
410 |
.................... #if defined(LCD_EXTENDED_NEWLINE) |
|
|
411 |
.................... g_LcdX = 0; |
|
|
412 |
.................... g_LcdY = 0; |
|
|
413 |
.................... #endif |
|
|
414 |
.................... break; |
|
|
415 |
.................... |
|
|
416 |
.................... #if defined(LCD_EXTENDED_NEWLINE) |
|
|
417 |
.................... case '\r' : lcd_gotoxy(1, g_LcdY+1); break; |
|
|
418 |
.................... case '\n' : |
|
|
419 |
.................... while (g_LcdX++ < LCD_LINE_LENGTH) |
|
|
420 |
.................... { |
|
|
421 |
.................... lcd_send_byte(1, ' '); |
|
|
422 |
.................... } |
|
|
423 |
.................... lcd_gotoxy(1, g_LcdY+2); |
|
|
424 |
.................... break; |
|
|
425 |
.................... #else |
|
|
426 |
.................... case '\n' : lcd_gotoxy(1,2); break; |
|
|
427 |
.................... #endif |
|
|
428 |
.................... |
|
|
429 |
.................... case '\b' : lcd_send_byte(0,0x10); break; |
|
|
430 |
.................... |
|
|
431 |
.................... #if defined(LCD_EXTENDED_NEWLINE) |
|
|
432 |
.................... default : |
|
|
433 |
.................... if (g_LcdX < LCD_LINE_LENGTH) |
|
|
434 |
.................... { |
|
|
435 |
.................... lcd_send_byte(1, c); |
|
|
436 |
.................... g_LcdX++; |
|
|
437 |
.................... } |
|
|
438 |
.................... break; |
|
|
439 |
.................... #else |
|
|
440 |
.................... default : lcd_send_byte(1,c); break; |
|
|
441 |
.................... #endif |
|
|
442 |
.................... } |
|
|
443 |
.................... } |
|
|
444 |
.................... |
|
|
445 |
.................... char lcd_getc(BYTE x, BYTE y) |
|
|
446 |
.................... { |
|
|
447 |
.................... char value; |
|
|
448 |
.................... |
|
|
449 |
.................... lcd_gotoxy(x,y); |
|
|
450 |
.................... while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low |
|
|
451 |
.................... lcd_output_rs(1); |
|
|
452 |
.................... value = lcd_read_byte(); |
|
|
453 |
.................... lcd_output_rs(0); |
|
|
454 |
.................... |
|
|
455 |
.................... return(value); |
|
|
456 |
.................... } |
|
|
457 |
.................... |
|
|
458 |
.................... |
|
|
459 |
.................... #define ONE_WIRE_PIN PIN_C7 |
|
|
460 |
.................... #use rs232(uart1, baud=9600) |
|
|
461 |
.................... |
|
|
462 |
.................... void main() |
|
|
463 |
.................... { |
|
|
464 |
* |
|
|
465 |
0066: CLRF 04 |
|
|
466 |
0067: BCF 03.7 |
|
|
467 |
0068: MOVLW 1F |
|
|
468 |
0069: ANDWF 03,F |
|
|
469 |
006A: MOVLW 71 |
|
|
470 |
006B: BSF 03.5 |
|
|
471 |
006C: MOVWF 0F |
|
|
472 |
006D: MOVF 0F,W |
|
|
473 |
006E: BSF 03.6 |
|
|
474 |
006F: BCF 07.3 |
|
|
475 |
0070: MOVLW 0C |
|
|
476 |
0071: BCF 03.6 |
|
|
477 |
0072: MOVWF 19 |
|
|
478 |
0073: MOVLW A2 |
|
|
479 |
0074: MOVWF 18 |
|
|
480 |
0075: MOVLW 90 |
|
|
481 |
0076: BCF 03.5 |
|
|
482 |
0077: MOVWF 18 |
|
|
483 |
0078: BSF 03.5 |
|
|
484 |
0079: BSF 03.6 |
|
|
485 |
007A: MOVF 09,W |
|
|
486 |
007B: ANDLW C0 |
|
|
487 |
007C: MOVWF 09 |
|
|
488 |
007D: BCF 03.6 |
|
|
489 |
007E: BCF 1F.4 |
|
|
490 |
007F: BCF 1F.5 |
|
|
491 |
0080: MOVLW 00 |
|
|
492 |
0081: BSF 03.6 |
|
|
493 |
0082: MOVWF 08 |
|
|
494 |
0083: BCF 03.5 |
|
|
495 |
0084: CLRF 07 |
|
|
496 |
0085: CLRF 08 |
|
|
497 |
0086: CLRF 09 |
|
|
498 |
.................... |
|
|
499 |
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD); |
|
|
500 |
* |
|
|
501 |
008A: BSF 03.5 |
|
|
502 |
008B: BSF 03.6 |
|
|
503 |
008C: MOVF 09,W |
|
|
504 |
008D: ANDLW C0 |
|
|
505 |
008E: MOVWF 09 |
|
|
506 |
008F: BCF 03.6 |
|
|
507 |
0090: BCF 1F.4 |
|
|
508 |
0091: BCF 1F.5 |
|
|
509 |
0092: MOVLW 00 |
|
|
510 |
0093: BSF 03.6 |
|
|
511 |
0094: MOVWF 08 |
|
|
512 |
.................... setup_adc(ADC_CLOCK_DIV_2); |
|
|
513 |
0095: BCF 03.5 |
|
|
514 |
0096: BCF 03.6 |
|
|
515 |
0097: BCF 1F.6 |
|
|
516 |
0098: BCF 1F.7 |
|
|
517 |
0099: BSF 03.5 |
|
|
518 |
009A: BCF 1F.7 |
|
|
519 |
009B: BCF 03.5 |
|
|
520 |
009C: BSF 1F.0 |
|
|
521 |
.................... setup_spi(SPI_SS_DISABLED); |
|
|
522 |
009D: BCF 14.5 |
|
|
523 |
009E: BCF 20.5 |
|
|
524 |
009F: MOVF 20,W |
|
|
525 |
00A0: BSF 03.5 |
|
|
526 |
00A1: MOVWF 07 |
|
|
527 |
00A2: BCF 03.5 |
|
|
528 |
00A3: BSF 20.4 |
|
|
529 |
00A4: MOVF 20,W |
|
|
530 |
00A5: BSF 03.5 |
|
|
531 |
00A6: MOVWF 07 |
|
|
532 |
00A7: BCF 03.5 |
|
|
533 |
00A8: BCF 20.3 |
|
|
534 |
00A9: MOVF 20,W |
|
|
535 |
00AA: BSF 03.5 |
|
|
536 |
00AB: MOVWF 07 |
|
|
537 |
00AC: MOVLW 01 |
|
|
538 |
00AD: BCF 03.5 |
|
|
539 |
00AE: MOVWF 14 |
|
|
540 |
00AF: MOVLW 00 |
|
|
541 |
00B0: BSF 03.5 |
|
|
542 |
00B1: MOVWF 14 |
|
|
543 |
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
544 |
00B2: MOVF 01,W |
|
|
545 |
00B3: ANDLW C7 |
|
|
546 |
00B4: IORLW 08 |
|
|
547 |
00B5: MOVWF 01 |
|
|
548 |
.................... setup_timer_1(T1_DISABLED); |
|
|
549 |
00B6: BCF 03.5 |
|
|
550 |
00B7: CLRF 10 |
|
|
551 |
.................... setup_timer_2(T2_DISABLED,0,1); |
|
|
552 |
00B8: MOVLW 00 |
|
|
553 |
00B9: MOVWF 78 |
|
|
554 |
00BA: MOVWF 12 |
|
|
555 |
00BB: MOVLW 00 |
|
|
556 |
00BC: BSF 03.5 |
|
|
557 |
00BD: MOVWF 12 |
|
|
558 |
.................... setup_ccp1(CCP_OFF); |
|
|
559 |
00BE: BCF 03.5 |
|
|
560 |
00BF: BSF 20.2 |
|
|
561 |
00C0: MOVF 20,W |
|
|
562 |
00C1: BSF 03.5 |
|
|
563 |
00C2: MOVWF 07 |
|
|
564 |
00C3: BCF 03.5 |
|
|
565 |
00C4: CLRF 17 |
|
|
566 |
00C5: BSF 03.5 |
|
|
567 |
00C6: CLRF 1B |
|
|
568 |
00C7: CLRF 1C |
|
|
569 |
00C8: MOVLW 01 |
|
|
570 |
00C9: MOVWF 1D |
|
|
571 |
.................... setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard |
|
|
572 |
00CA: BCF 03.5 |
|
|
573 |
00CB: BSF 03.6 |
|
|
574 |
00CC: CLRF 07 |
|
|
575 |
00CD: CLRF 08 |
|
|
576 |
00CE: CLRF 09 |
|
|
577 |
.................... setup_oscillator(OSC_8MHZ); |
|
|
578 |
00CF: MOVLW 71 |
|
|
579 |
00D0: BSF 03.5 |
|
|
580 |
00D1: BCF 03.6 |
|
|
581 |
00D2: MOVWF 0F |
|
|
582 |
00D3: MOVF 0F,W |
|
|
583 |
.................... |
|
|
584 |
.................... |
|
|
585 |
.................... printf("Simple Thermomether",); |
|
|
586 |
00D4: MOVLW 04 |
|
|
587 |
00D5: BCF 03.5 |
|
|
588 |
00D6: BSF 03.6 |
|
|
589 |
00D7: MOVWF 0D |
|
|
590 |
00D8: MOVLW 00 |
|
|
591 |
00D9: MOVWF 0F |
|
|
592 |
00DA: BCF 03.6 |
|
|
593 |
00DB: CALL 01E |
|
|
594 |
.................... printf("(c) Kaklik 2013\r\n"); |
|
|
595 |
00DC: MOVLW 0E |
|
|
596 |
00DD: BSF 03.6 |
|
|
597 |
00DE: MOVWF 0D |
|
|
598 |
00DF: MOVLW 00 |
|
|
599 |
00E0: MOVWF 0F |
|
|
600 |
00E1: BCF 03.6 |
|
|
601 |
00E2: CALL 01E |
|
|
602 |
.................... printf("www.mlab.cz\r\n"); |
|
|
603 |
00E3: MOVLW 17 |
|
|
604 |
00E4: BSF 03.6 |
|
|
605 |
00E5: MOVWF 0D |
|
|
606 |
00E6: MOVLW 00 |
|
|
607 |
00E7: MOVWF 0F |
|
|
608 |
00E8: BCF 03.6 |
|
|
609 |
00E9: CALL 01E |
|
|
610 |
.................... |
|
|
611 |
.................... |
|
|
612 |
.................... while (TRUE) |
|
|
613 |
.................... { |
|
|
614 |
.................... |
|
|
615 |
.................... } |
|
|
616 |
00EA: GOTO 0EA |
|
|
617 |
.................... |
|
|
618 |
.................... } |
|
|
619 |
00EB: SLEEP |
|
|
620 |
|
|
|
621 |
Configuration Fuses: |
|
|
622 |
Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG |
|
|
623 |
Word 2: 3FFF NOWRT BORV40 |