CCS PCM C Compiler, Version 4.106, 47914 27-4-14 20:11Filename: D:\Honza\MLAB\Modules\HumanInterfaces\LCD2L4P02A\SW\PIC\PIC16F887\main.lstROM used: 669 words (8%)Largest free fragment is 2048RAM used: 9 (2%) at main() level22 (6%) worst caseStack: 5 locations*0000: MOVLW 010001: MOVWF 0A0002: GOTO 1E50003: NOP.................... #include "main.h".................... #include <16F887.h>.................... //////// Standard Header file for the PIC16F887 device ////////////////.................... #device PIC16F887.................... #list........................................ #device adc=10........................................ #FUSES NOWDT //No Watch Dog Timer.................... #FUSES INTRC //Internal RC Osc.................... #FUSES NOPUT //No Power Up Timer.................... #FUSES MCLR //Master Clear pin enabled.................... #FUSES NOPROTECT //Code not protected from reading.................... #FUSES NOCPD //No EE protection.................... #FUSES NOBROWNOUT //No brownout reset.................... #FUSES IESO //Internal External Switch Over mode enabled.................... #FUSES FCMEN //Fail-safe clock monitor enabled.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O.................... #FUSES NODEBUG //No Debug mode for ICD.................... #FUSES NOWRT //Program memory not write protected.................... #FUSES BORV40 //Brownout reset at 4.0V........................................ #use delay(clock=8000000)*001F: MOVLW 270020: MOVWF 040021: BCF 03.70022: MOVF 00,W0023: BTFSC 03.20024: GOTO 0320025: MOVLW 020026: MOVWF 780027: CLRF 770028: DECFSZ 77,F0029: GOTO 028002A: DECFSZ 78,F002B: GOTO 027002C: MOVLW 97002D: MOVWF 77002E: DECFSZ 77,F002F: GOTO 02E0030: DECFSZ 00,F0031: GOTO 0250032: RETURN.................... #use i2c(master, sda=PIN_C4, scl=PIN_C3).................... #use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)................................................................................ #define LCD_ENABLE_PIN PIN_E0 ////.................... #define LCD_RS_PIN PIN_E1 ////.................... #define LCD_RW_PIN PIN_E2 ////.................... #define LCD_DATA4 PIN_D4 ////.................... #define LCD_DATA5 PIN_D5 ////.................... #define LCD_DATA6 PIN_D6 ////.................... #define LCD_DATA7 PIN_D7.................... #include <lcd.c>.................... ///////////////////////////////////////////////////////////////////////////////.................... //// LCD.C ////.................... //// Driver for common LCD modules ////.................... //// ////.................... //// lcd_init() Must be called before any other function. ////.................... //// ////.................... //// lcd_putc(c) Will display c on the next position of the LCD. ////.................... //// \a Set cursor position to upper left ////.................... //// \f Clear display, set cursor to upper left ////.................... //// \n Go to start of second line ////.................... //// \b Move back one position ////.................... //// If LCD_EXTENDED_NEWLINE is defined, the \n character ////.................... //// will erase all remanining characters on the current ////.................... //// line, and move the cursor to the beginning of the next ////.................... //// line. ////.................... //// If LCD_EXTENDED_NEWLINE is defined, the \r character ////.................... //// will move the cursor to the start of the current ////.................... //// line. ////.................... //// ////.................... //// lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1) ////.................... //// ////.................... //// lcd_getc(x,y) Returns character at position x,y on LCD ////.................... //// ////.................... //// CONFIGURATION ////.................... //// The LCD can be configured in one of two ways: a.) port access or ////.................... //// b.) pin access. Port access requires the entire 7 bit interface ////.................... //// connected to one GPIO port, and the data bits (D4:D7 of the LCD) ////.................... //// connected to sequential pins on the GPIO. Pin access ////.................... //// has no requirements, all 7 bits of the control interface can ////.................... //// can be connected to any GPIO using several ports. ////.................... //// ////.................... //// To use port access, #define LCD_DATA_PORT to the SFR location of ////.................... //// of the GPIO port that holds the interface, -AND- edit LCD_PIN_MAP ////.................... //// of this file to configure the pin order. If you are using a ////.................... //// baseline PIC (PCB), then LCD_OUTPUT_MAP and LCD_INPUT_MAP also must ////.................... //// be defined. ////.................... //// ////.................... //// Example of port access: ////.................... //// #define LCD_DATA_PORT getenv("SFR:PORTD") ////.................... //// ////.................... //// To use pin access, the following pins must be defined: ////.................... //// LCD_ENABLE_PIN ////.................... //// LCD_RS_PIN ////.................... //// LCD_RW_PIN ////.................... //// LCD_DATA4 ////.................... //// LCD_DATA5 ////.................... //// LCD_DATA6 ////.................... //// LCD_DATA7 ////.................... //// ////.................... //// Example of pin access: ////.................... //// #define LCD_ENABLE_PIN PIN_E0 ////.................... //// #define LCD_RS_PIN PIN_E1 ////.................... //// #define LCD_RW_PIN PIN_E2 ////.................... //// #define LCD_DATA4 PIN_D4 ////.................... //// #define LCD_DATA5 PIN_D5 ////.................... //// #define LCD_DATA6 PIN_D6 ////.................... //// #define LCD_DATA7 PIN_D7 ////.................... //// ////.................... ///////////////////////////////////////////////////////////////////////////////.................... //// (C) Copyright 1996,2010 Custom Computer Services ////.................... //// This source code may only be used by licensed users of the CCS C ////.................... //// compiler. This source code may only be distributed to other ////.................... //// licensed users of the CCS C compiler. No other use, reproduction ////.................... //// or distribution is permitted without written permission. ////.................... //// Derivative programs created using this software in object code ////.................... //// form are not restricted in any way. ////.................... ///////////////////////////////////////////////////////////////////////////........................................ // define the pinout..................... // only required if port access is being used..................... typedef struct.................... { // This structure is overlayed.................... BOOLEAN enable; // on to an I/O port to gain.................... BOOLEAN rs; // access to the LCD pins..................... BOOLEAN rw; // The bits are allocated from.................... BOOLEAN unused; // low order up. ENABLE will.................... int data : 4; // be LSB pin of that port..................... #if defined(__PCD__) // The port used will be LCD_DATA_PORT..................... int reserved: 8;.................... #endif.................... } LCD_PIN_MAP;........................................ // this is to improve compatability with previous LCD drivers that accepted.................... // a define labeled 'use_portb_lcd' that configured the LCD onto port B..................... #if ((defined(use_portb_lcd)) && (use_portb_lcd==TRUE)).................... #define LCD_DATA_PORT getenv("SFR:PORTB").................... #endif........................................ #if defined(__PCB__).................... // these definitions only need to be modified for baseline PICs..................... // all other PICs use LCD_PIN_MAP or individual LCD_xxx pin definitions..................... /* EN, RS, RW, UNUSED, DATA */.................... const LCD_PIN_MAP LCD_OUTPUT_MAP = {0, 0, 0, 0, 0};.................... const LCD_PIN_MAP LCD_INPUT_MAP = {0, 0, 0, 0, 0xF};.................... #endif........................................ ////////////////////// END CONFIGURATION ///////////////////////////////////........................................ #ifndef LCD_ENABLE_PIN.................... #define lcd_output_enable(x) lcdlat.enable=x.................... #define lcd_enable_tris() lcdtris.enable=0.................... #else.................... #define lcd_output_enable(x) output_bit(LCD_ENABLE_PIN, x).................... #define lcd_enable_tris() output_drive(LCD_ENABLE_PIN).................... #endif........................................ #ifndef LCD_RS_PIN.................... #define lcd_output_rs(x) lcdlat.rs=x.................... #define lcd_rs_tris() lcdtris.rs=0.................... #else.................... #define lcd_output_rs(x) output_bit(LCD_RS_PIN, x).................... #define lcd_rs_tris() output_drive(LCD_RS_PIN).................... #endif........................................ #ifndef LCD_RW_PIN.................... #define lcd_output_rw(x) lcdlat.rw=x.................... #define lcd_rw_tris() lcdtris.rw=0.................... #else.................... #define lcd_output_rw(x) output_bit(LCD_RW_PIN, x).................... #define lcd_rw_tris() output_drive(LCD_RW_PIN).................... #endif........................................ // original version of this library incorrectly labeled LCD_DATA0 as LCD_DATA4,.................... // LCD_DATA1 as LCD_DATA5, and so on. this block of code makes the driver.................... // compatible with any code written for the original library.................... #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)).................... #define LCD_DATA4 LCD_DATA0.................... #define LCD_DATA5 LCD_DATA1.................... #define LCD_DATA6 LCD_DATA2.................... #define LCD_DATA7 LCD_DATA3.................... #endif........................................ #ifndef LCD_DATA4.................... #ifndef LCD_DATA_PORT.................... #if defined(__PCB__).................... #define LCD_DATA_PORT 0x06 //portb.................... #define set_tris_lcd(x) set_tris_b(x).................... #else.................... #if defined(PIN_D0).................... #define LCD_DATA_PORT getenv("SFR:PORTD") //portd.................... #else.................... #define LCD_DATA_PORT getenv("SFR:PORTB") //portb.................... #endif.................... #endif.................... #endif........................................ #if defined(__PCB__).................... LCD_PIN_MAP lcd, lcdlat;.................... #byte lcd = LCD_DATA_PORT.................... #byte lcdlat = LCD_DATA_PORT.................... #elif defined(__PCM__).................... LCD_PIN_MAP lcd, lcdlat, lcdtris;.................... #byte lcd = LCD_DATA_PORT.................... #byte lcdlat = LCD_DATA_PORT.................... #byte lcdtris = LCD_DATA_PORT+0x80.................... #elif defined(__PCH__).................... LCD_PIN_MAP lcd, lcdlat, lcdtris;.................... #byte lcd = LCD_DATA_PORT.................... #byte lcdlat = LCD_DATA_PORT+9.................... #byte lcdtris = LCD_DATA_PORT+0x12.................... #elif defined(__PCD__).................... LCD_PIN_MAP lcd, lcdlat, lcdtris;.................... #word lcd = LCD_DATA_PORT.................... #word lcdlat = LCD_DATA_PORT+2.................... #word lcdtris = LCD_DATA_PORT-0x02.................... #endif.................... #endif //LCD_DATA4 not defined........................................ #ifndef LCD_TYPE.................... #define LCD_TYPE 2 // 0=5x7, 1=5x10, 2=2 lines.................... #endif........................................ #ifndef LCD_LINE_TWO.................... #define LCD_LINE_TWO 0x40 // LCD RAM address for the second line.................... #endif........................................ #ifndef LCD_LINE_LENGTH.................... #define LCD_LINE_LENGTH 20.................... #endif........................................ BYTE const LCD_INIT_STRING[4] = {0x20 | (LCD_TYPE << 2), 0xc, 1, 6};.................... // These bytes need to be sent to the LCD.................... // to start it up......................................... BYTE lcd_read_nibble(void);........................................ BYTE lcd_read_byte(void).................... {.................... BYTE low,high;........................................ #if defined(__PCB__).................... set_tris_lcd(LCD_INPUT_MAP);.................... #else.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)).................... output_float(LCD_DATA4);*0098: BSF 08.4.................... output_float(LCD_DATA5);0099: BSF 08.5.................... output_float(LCD_DATA6);009A: BSF 08.6.................... output_float(LCD_DATA7);009B: BSF 08.7.................... #else.................... lcdtris.data = 0xF;.................... #endif.................... #endif........................................ lcd_output_rw(1);009C: BCF 03.5009D: BSF 09.2009E: BSF 03.5009F: BCF 09.2.................... delay_cycles(1);00A0: NOP.................... lcd_output_enable(1);00A1: BCF 03.500A2: BSF 09.000A3: BSF 03.500A4: BCF 09.0.................... delay_cycles(1);00A5: NOP.................... high = lcd_read_nibble();00A6: BCF 03.500A7: CALL 05F00A8: MOVF 78,W00A9: MOVWF 2E........................................ lcd_output_enable(0);00AA: BCF 09.000AB: BSF 03.500AC: BCF 09.0.................... delay_cycles(1);00AD: NOP.................... lcd_output_enable(1);00AE: BCF 03.500AF: BSF 09.000B0: BSF 03.500B1: BCF 09.0.................... delay_us(1);00B2: GOTO 0B3.................... low = lcd_read_nibble();00B3: BCF 03.500B4: CALL 05F00B5: MOVF 78,W00B6: MOVWF 2D........................................ lcd_output_enable(0);00B7: BCF 09.000B8: BSF 03.500B9: BCF 09.0........................................ #if defined(__PCB__).................... set_tris_lcd(LCD_OUTPUT_MAP);.................... #else.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)).................... output_drive(LCD_DATA4);00BA: BCF 08.4.................... output_drive(LCD_DATA5);00BB: BCF 08.5.................... output_drive(LCD_DATA6);00BC: BCF 08.6.................... output_drive(LCD_DATA7);00BD: BCF 08.7.................... #else.................... lcdtris.data = 0x0;.................... #endif.................... #endif........................................ return( (high<<4) | low);00BE: BCF 03.500BF: SWAPF 2E,W00C0: MOVWF 7700C1: MOVLW F000C2: ANDWF 77,F00C3: MOVF 77,W00C4: IORWF 2D,W00C5: MOVWF 78.................... }........................................ BYTE lcd_read_nibble(void).................... {.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7))*005F: CLRF 2F.................... BYTE n = 0x00;........................................ /* Read the data port */.................... n |= input(LCD_DATA4);0060: BSF 03.50061: BSF 08.40062: MOVLW 000063: BCF 03.50064: BTFSC 08.40065: MOVLW 010066: IORWF 2F,F.................... n |= input(LCD_DATA5) << 1;0067: BSF 03.50068: BSF 08.50069: MOVLW 00006A: BCF 03.5006B: BTFSC 08.5006C: MOVLW 01006D: MOVWF 77006E: BCF 03.0006F: RLF 77,F0070: MOVF 77,W0071: IORWF 2F,F.................... n |= input(LCD_DATA6) << 2;0072: BSF 03.50073: BSF 08.60074: MOVLW 000075: BCF 03.50076: BTFSC 08.60077: MOVLW 010078: MOVWF 770079: RLF 77,F007A: RLF 77,F007B: MOVLW FC007C: ANDWF 77,F007D: MOVF 77,W007E: IORWF 2F,F.................... n |= input(LCD_DATA7) << 3;007F: BSF 03.50080: BSF 08.70081: MOVLW 000082: BCF 03.50083: BTFSC 08.70084: MOVLW 010085: MOVWF 770086: RLF 77,F0087: RLF 77,F0088: RLF 77,F0089: MOVLW F8008A: ANDWF 77,F008B: MOVF 77,W008C: IORWF 2F,F........................................ return(n);008D: MOVF 2F,W008E: MOVWF 78.................... #else.................... return(lcd.data);.................... #endif.................... }008F: RETURN........................................ void lcd_send_nibble(BYTE n).................... {.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)).................... /* Write to the data port */.................... output_bit(LCD_DATA4, bit_test(n, 0));*0033: BTFSC 2E.00034: GOTO 0370035: BCF 08.40036: GOTO 0380037: BSF 08.40038: BSF 03.50039: BCF 08.4.................... output_bit(LCD_DATA5, bit_test(n, 1));003A: BCF 03.5003B: BTFSC 2E.1003C: GOTO 03F003D: BCF 08.5003E: GOTO 040003F: BSF 08.50040: BSF 03.50041: BCF 08.5.................... output_bit(LCD_DATA6, bit_test(n, 2));0042: BCF 03.50043: BTFSC 2E.20044: GOTO 0470045: BCF 08.60046: GOTO 0480047: BSF 08.60048: BSF 03.50049: BCF 08.6.................... output_bit(LCD_DATA7, bit_test(n, 3));004A: BCF 03.5004B: BTFSC 2E.3004C: GOTO 04F004D: BCF 08.7004E: GOTO 050004F: BSF 08.70050: BSF 03.50051: BCF 08.7.................... #else.................... lcdlat.data = n;.................... #endif........................................ delay_cycles(1);0052: NOP.................... lcd_output_enable(1);0053: BCF 03.50054: BSF 09.00055: BSF 03.50056: BCF 09.0.................... delay_us(2);0057: GOTO 0580058: GOTO 059.................... lcd_output_enable(0);0059: BCF 03.5005A: BCF 09.0005B: BSF 03.5005C: BCF 09.0.................... }005D: BCF 03.5005E: RETURN........................................ void lcd_send_byte(BYTE address, BYTE n).................... {.................... #if defined(__PCB__).................... set_tris_lcd(LCD_OUTPUT_MAP);.................... #else.................... lcd_enable_tris();*0090: BSF 03.50091: BCF 09.0.................... lcd_rs_tris();0092: BCF 09.1.................... lcd_rw_tris();0093: BCF 09.2.................... #endif........................................ lcd_output_rs(0);0094: BCF 03.50095: BCF 09.10096: BSF 03.50097: BCF 09.1.................... while ( bit_test(lcd_read_byte(),7) ) ;*00C6: MOVF 78,W00C7: MOVWF 2D00C8: BTFSS 2D.700C9: GOTO 0CC00CA: BSF 03.500CB: GOTO 098.................... lcd_output_rs(address);00CC: MOVF 2B,F00CD: BTFSS 03.200CE: GOTO 0D100CF: BCF 09.100D0: GOTO 0D200D1: BSF 09.100D2: BSF 03.500D3: BCF 09.1.................... delay_cycles(1);00D4: NOP.................... lcd_output_rw(0);00D5: BCF 03.500D6: BCF 09.200D7: BSF 03.500D8: BCF 09.2.................... delay_cycles(1);00D9: NOP.................... lcd_output_enable(0);00DA: BCF 03.500DB: BCF 09.000DC: BSF 03.500DD: BCF 09.0.................... lcd_send_nibble(n >> 4);00DE: BCF 03.500DF: SWAPF 2C,W00E0: MOVWF 2D00E1: MOVLW 0F00E2: ANDWF 2D,F00E3: MOVF 2D,W00E4: MOVWF 2E00E5: CALL 033.................... lcd_send_nibble(n & 0xf);00E6: MOVF 2C,W00E7: ANDLW 0F00E8: MOVWF 2D00E9: MOVWF 2E00EA: CALL 033.................... }00EB: RETURN........................................ #if defined(LCD_EXTENDED_NEWLINE).................... unsigned int8 g_LcdX, g_LcdY;.................... #endif........................................ void lcd_init(void).................... {.................... BYTE i;........................................ #if defined(__PCB__).................... set_tris_lcd(LCD_OUTPUT_MAP);.................... #else.................... #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)).................... output_drive(LCD_DATA4);00EC: BSF 03.500ED: BCF 08.4.................... output_drive(LCD_DATA5);00EE: BCF 08.5.................... output_drive(LCD_DATA6);00EF: BCF 08.6.................... output_drive(LCD_DATA7);00F0: BCF 08.7.................... #else.................... lcdtris.data = 0x0;.................... #endif.................... lcd_enable_tris();00F1: BCF 09.0.................... lcd_rs_tris();00F2: BCF 09.1.................... lcd_rw_tris();00F3: BCF 09.2.................... #endif........................................ lcd_output_rs(0);00F4: BCF 03.500F5: BCF 09.100F6: BSF 03.500F7: BCF 09.1.................... lcd_output_rw(0);00F8: BCF 03.500F9: BCF 09.200FA: BSF 03.500FB: BCF 09.2.................... lcd_output_enable(0);00FC: BCF 03.500FD: BCF 09.000FE: BSF 03.500FF: BCF 09.0........................................ delay_ms(15);0100: MOVLW 0F0101: BCF 03.50102: MOVWF 270103: CALL 01F.................... for(i=1;i<=3;++i)0104: MOVLW 010105: MOVWF 230106: MOVF 23,W0107: SUBLW 030108: BTFSS 03.00109: GOTO 112.................... {.................... lcd_send_nibble(3);010A: MOVLW 03010B: MOVWF 2E010C: CALL 033.................... delay_ms(5);010D: MOVLW 05010E: MOVWF 27010F: CALL 01F.................... }0110: INCF 23,F0111: GOTO 106........................................ lcd_send_nibble(2);0112: MOVLW 020113: MOVWF 2E0114: CALL 033.................... for(i=0;i<=3;++i)0115: CLRF 230116: MOVF 23,W0117: SUBLW 030118: BTFSS 03.00119: GOTO 123.................... lcd_send_byte(0,LCD_INIT_STRING[i]);011A: MOVF 23,W011B: CALL 004011C: MOVWF 24011D: CLRF 2B011E: MOVF 24,W011F: MOVWF 2C0120: CALL 090........................................ #if defined(LCD_EXTENDED_NEWLINE)0121: INCF 23,F0122: GOTO 116.................... g_LcdX = 0;.................... g_LcdY = 0;.................... #endif.................... }0123: RETURN........................................ void lcd_gotoxy(BYTE x, BYTE y).................... {.................... BYTE address;........................................ if(y!=1)0124: DECFSZ 28,W0125: GOTO 1270126: GOTO 12A.................... address=LCD_LINE_TWO;0127: MOVLW 400128: MOVWF 29.................... else0129: GOTO 12B.................... address=0;012A: CLRF 29........................................ address+=x-1;012B: MOVLW 01012C: SUBWF 27,W012D: ADDWF 29,F.................... lcd_send_byte(0,0x80|address);012E: MOVF 29,W012F: IORLW 800130: MOVWF 2A0131: CLRF 2B0132: MOVF 2A,W0133: MOVWF 2C0134: CALL 090........................................ #if defined(LCD_EXTENDED_NEWLINE).................... g_LcdX = x - 1;.................... g_LcdY = y - 1;.................... #endif.................... }0135: RETURN........................................ void lcd_putc(char c).................... {.................... switch (c).................... {0136: MOVF 26,W0137: XORLW 070138: BTFSC 03.20139: GOTO 144013A: XORLW 0B013B: BTFSC 03.2013C: GOTO 149013D: XORLW 06013E: BTFSC 03.2013F: GOTO 1510140: XORLW 020141: BTFSC 03.20142: GOTO 1570143: GOTO 15C.................... case '\a' : lcd_gotoxy(1,1); break;0144: MOVLW 010145: MOVWF 270146: MOVWF 280147: CALL 1240148: GOTO 162........................................ case '\f' : lcd_send_byte(0,1);0149: CLRF 2B014A: MOVLW 01014B: MOVWF 2C014C: CALL 090.................... delay_ms(2);014D: MOVLW 02014E: MOVWF 27014F: CALL 01F.................... #if defined(LCD_EXTENDED_NEWLINE).................... g_LcdX = 0;.................... g_LcdY = 0;.................... #endif.................... break;0150: GOTO 162........................................ #if defined(LCD_EXTENDED_NEWLINE).................... case '\r' : lcd_gotoxy(1, g_LcdY+1); break;.................... case '\n' :.................... while (g_LcdX++ < LCD_LINE_LENGTH).................... {.................... lcd_send_byte(1, ' ');.................... }.................... lcd_gotoxy(1, g_LcdY+2);.................... break;.................... #else.................... case '\n' : lcd_gotoxy(1,2); break;0151: MOVLW 010152: MOVWF 270153: MOVLW 020154: MOVWF 280155: CALL 1240156: GOTO 162.................... #endif........................................ case '\b' : lcd_send_byte(0,0x10); break;0157: CLRF 2B0158: MOVLW 100159: MOVWF 2C015A: CALL 090015B: GOTO 162........................................ #if defined(LCD_EXTENDED_NEWLINE).................... default :.................... if (g_LcdX < LCD_LINE_LENGTH).................... {.................... lcd_send_byte(1, c);.................... g_LcdX++;.................... }.................... break;.................... #else.................... default : lcd_send_byte(1,c); break;015C: MOVLW 01015D: MOVWF 2B015E: MOVF 26,W015F: MOVWF 2C0160: CALL 0900161: GOTO 162.................... #endif.................... }.................... }0162: RETURN........................................ char lcd_getc(BYTE x, BYTE y).................... {.................... char value;........................................ lcd_gotoxy(x,y);.................... while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low.................... lcd_output_rs(1);.................... value = lcd_read_byte();.................... lcd_output_rs(0);........................................ return(value);.................... }............................................................ #define BEEPER PIN_B5........................................ int beep().................... {.................... unsigned int i;........................................ i=0;*01CC: CLRF 23.................... for(i=0;i<100;i++)01CD: CLRF 2301CE: MOVF 23,W01CF: SUBLW 6301D0: BTFSS 03.001D1: GOTO 1E2.................... {.................... output_low(BEEPER);01D2: BSF 03.501D3: BCF 06.501D4: BCF 03.501D5: BCF 06.5.................... delay_ms(1);01D6: MOVLW 0101D7: MOVWF 2701D8: CALL 01F.................... output_high(BEEPER);01D9: BSF 03.501DA: BCF 06.501DB: BCF 03.501DC: BSF 06.5.................... delay_ms(1);01DD: MOVLW 0101DE: MOVWF 2701DF: CALL 01F.................... }01E0: INCF 23,F01E1: GOTO 1CE.................... }01E2: BCF 0A.301E3: BCF 0A.401E4: GOTO 294 (RETURN)............................................................ void main().................... {01E5: CLRF 0401E6: BCF 03.701E7: MOVLW 1F01E8: ANDWF 03,F01E9: MOVLW 7101EA: BSF 03.501EB: MOVWF 0F01EC: MOVF 0F,W01ED: BSF 03.601EE: BCF 07.301EF: MOVLW 0C01F0: BCF 03.601F1: MOVWF 1901F2: MOVLW A201F3: MOVWF 1801F4: MOVLW 9001F5: BCF 03.501F6: MOVWF 1801F7: BSF 03.501F8: BSF 03.601F9: MOVF 09,W01FA: ANDLW C001FB: MOVWF 0901FC: BCF 03.601FD: BCF 1F.401FE: BCF 1F.501FF: MOVLW 000200: BSF 03.60201: MOVWF 080202: BCF 03.50203: CLRF 070204: CLRF 080205: CLRF 09*0209: CLRF 22020A: CLRF 21.................... int16 i=0;........................................ setup_adc_ports(NO_ANALOGS|VSS_VDD);020B: BSF 03.5020C: BSF 03.6020D: MOVF 09,W020E: ANDLW C0020F: MOVWF 090210: BCF 03.60211: BCF 1F.40212: BCF 1F.50213: MOVLW 000214: BSF 03.60215: MOVWF 08.................... setup_adc(ADC_CLOCK_DIV_2);0216: BCF 03.50217: BCF 03.60218: BCF 1F.60219: BCF 1F.7021A: BSF 03.5021B: BSF 1F.7021C: BCF 03.5021D: BSF 1F.0.................... setup_spi(SPI_SS_DISABLED);021E: BCF 14.5021F: BCF 20.50220: MOVF 20,W0221: BSF 03.50222: MOVWF 070223: BCF 03.50224: BSF 20.40225: MOVF 20,W0226: BSF 03.50227: MOVWF 070228: BCF 03.50229: BCF 20.3022A: MOVF 20,W022B: BSF 03.5022C: MOVWF 07022D: MOVLW 01022E: BCF 03.5022F: MOVWF 140230: MOVLW 000231: BSF 03.50232: MOVWF 14.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);0233: MOVF 01,W0234: ANDLW C70235: IORLW 080236: MOVWF 01.................... setup_timer_1(T1_DISABLED);0237: BCF 03.50238: CLRF 10.................... setup_timer_2(T2_DISABLED,0,1);0239: MOVLW 00023A: MOVWF 78023B: MOVWF 12023C: MOVLW 00023D: BSF 03.5023E: MOVWF 12.................... setup_ccp1(CCP_OFF);023F: BCF 03.50240: BSF 20.20241: MOVF 20,W0242: BSF 03.50243: MOVWF 070244: BCF 03.50245: CLRF 170246: BSF 03.50247: CLRF 1B0248: CLRF 1C0249: MOVLW 01024A: MOVWF 1D.................... setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard024B: BCF 03.5024C: BSF 03.6024D: CLRF 07024E: CLRF 08024F: CLRF 09.................... setup_oscillator(OSC_8MHZ);0250: MOVLW 710251: BSF 03.50252: BCF 03.60253: MOVWF 0F0254: MOVF 0F,W........................................ lcd_init();0255: BCF 03.50256: CALL 0EC.................... lcd_putc("(c) Kaklik 2013");0257: MOVLW 0C0258: BSF 03.60259: MOVWF 0D025A: MOVLW 00025B: MOVWF 0F025C: BCF 03.6025D: CALL 163.................... lcd_gotoxy(3,2);025E: MOVLW 03025F: MOVWF 270260: MOVLW 020261: MOVWF 280262: CALL 124.................... lcd_putc("www.mlab.cz");0263: MOVLW 140264: BSF 03.60265: MOVWF 0D0266: MOVLW 000267: MOVWF 0F0268: BCF 03.60269: CALL 163.................... Delay_ms(2000);026A: MOVLW 08026B: MOVWF 23026C: MOVLW FA026D: MOVWF 27026E: CALL 01F026F: DECFSZ 23,F0270: GOTO 26C.................... lcd_init();0271: CALL 0EC........................................ while (TRUE).................... {.................... lcd_gotoxy(1,1);0272: MOVLW 010273: MOVWF 270274: MOVWF 280275: CALL 124........................................ printf(lcd_putc,"LCD test");0276: MOVLW 1A0277: BSF 03.60278: MOVWF 0D0279: MOVLW 00027A: MOVWF 0F027B: BCF 03.6027C: CALL 163.................... lcd_gotoxy(1,2);027D: MOVLW 01027E: MOVWF 27027F: MOVLW 020280: MOVWF 280281: CALL 124.................... printf(lcd_putc,"%c %x ",i,i);0282: MOVF 21,W0283: MOVWF 260284: CALL 1360285: MOVLW 200286: MOVWF 260287: CALL 1360288: MOVF 21,W0289: MOVWF 23028A: MOVLW 57028B: MOVWF 24028C: GOTO 1A9028D: MOVLW 20028E: MOVWF 26028F: CALL 136.................... i++;0290: INCF 21,F0291: BTFSC 03.20292: INCF 22,F.................... beep();0293: GOTO 1CC.................... Delay_ms(500);0294: MOVLW 020295: MOVWF 230296: MOVLW FA0297: MOVWF 270298: CALL 01F0299: DECFSZ 23,F029A: GOTO 296.................... }029B: GOTO 272........................................ }029C: SLEEPConfiguration Fuses:Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUGWord 2: 3FFF NOWRT BORV40