CCS PCM C Compiler, Version 4.106, 47914 27-4-14 20:11
Filename: D:\Honza\MLAB\Modules\HumanInterfaces\LCD2L4P02A\SW\PIC\PIC16F887\main.lst
ROM used: 669 words (8%)
Largest free fragment is 2048
RAM used: 9 (2%) at main() level
22 (6%) worst case
Stack: 5 locations
*
0000: MOVLW 01
0001: MOVWF 0A
0002: GOTO 1E5
0003: 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 27
0020: MOVWF 04
0021: BCF 03.7
0022: MOVF 00,W
0023: BTFSC 03.2
0024: GOTO 032
0025: MOVLW 02
0026: MOVWF 78
0027: CLRF 77
0028: DECFSZ 77,F
0029: GOTO 028
002A: DECFSZ 78,F
002B: GOTO 027
002C: MOVLW 97
002D: MOVWF 77
002E: DECFSZ 77,F
002F: GOTO 02E
0030: DECFSZ 00,F
0031: GOTO 025
0032: 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.5
009D: BSF 09.2
009E: BSF 03.5
009F: BCF 09.2
.................... delay_cycles(1);
00A0: NOP
.................... lcd_output_enable(1);
00A1: BCF 03.5
00A2: BSF 09.0
00A3: BSF 03.5
00A4: BCF 09.0
.................... delay_cycles(1);
00A5: NOP
.................... high = lcd_read_nibble();
00A6: BCF 03.5
00A7: CALL 05F
00A8: MOVF 78,W
00A9: MOVWF 2E
....................
.................... lcd_output_enable(0);
00AA: BCF 09.0
00AB: BSF 03.5
00AC: BCF 09.0
.................... delay_cycles(1);
00AD: NOP
.................... lcd_output_enable(1);
00AE: BCF 03.5
00AF: BSF 09.0
00B0: BSF 03.5
00B1: BCF 09.0
.................... delay_us(1);
00B2: GOTO 0B3
.................... low = lcd_read_nibble();
00B3: BCF 03.5
00B4: CALL 05F
00B5: MOVF 78,W
00B6: MOVWF 2D
....................
.................... lcd_output_enable(0);
00B7: BCF 09.0
00B8: BSF 03.5
00B9: 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.5
00BF: SWAPF 2E,W
00C0: MOVWF 77
00C1: MOVLW F0
00C2: ANDWF 77,F
00C3: MOVF 77,W
00C4: IORWF 2D,W
00C5: 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.5
0061: BSF 08.4
0062: MOVLW 00
0063: BCF 03.5
0064: BTFSC 08.4
0065: MOVLW 01
0066: IORWF 2F,F
.................... n |= input(LCD_DATA5) << 1;
0067: BSF 03.5
0068: BSF 08.5
0069: MOVLW 00
006A: BCF 03.5
006B: BTFSC 08.5
006C: MOVLW 01
006D: MOVWF 77
006E: BCF 03.0
006F: RLF 77,F
0070: MOVF 77,W
0071: IORWF 2F,F
.................... n |= input(LCD_DATA6) << 2;
0072: BSF 03.5
0073: BSF 08.6
0074: MOVLW 00
0075: BCF 03.5
0076: BTFSC 08.6
0077: MOVLW 01
0078: MOVWF 77
0079: RLF 77,F
007A: RLF 77,F
007B: MOVLW FC
007C: ANDWF 77,F
007D: MOVF 77,W
007E: IORWF 2F,F
.................... n |= input(LCD_DATA7) << 3;
007F: BSF 03.5
0080: BSF 08.7
0081: MOVLW 00
0082: BCF 03.5
0083: BTFSC 08.7
0084: MOVLW 01
0085: MOVWF 77
0086: RLF 77,F
0087: RLF 77,F
0088: RLF 77,F
0089: MOVLW F8
008A: ANDWF 77,F
008B: MOVF 77,W
008C: IORWF 2F,F
....................
.................... return(n);
008D: MOVF 2F,W
008E: 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.0
0034: GOTO 037
0035: BCF 08.4
0036: GOTO 038
0037: BSF 08.4
0038: BSF 03.5
0039: BCF 08.4
.................... output_bit(LCD_DATA5, bit_test(n, 1));
003A: BCF 03.5
003B: BTFSC 2E.1
003C: GOTO 03F
003D: BCF 08.5
003E: GOTO 040
003F: BSF 08.5
0040: BSF 03.5
0041: BCF 08.5
.................... output_bit(LCD_DATA6, bit_test(n, 2));
0042: BCF 03.5
0043: BTFSC 2E.2
0044: GOTO 047
0045: BCF 08.6
0046: GOTO 048
0047: BSF 08.6
0048: BSF 03.5
0049: BCF 08.6
.................... output_bit(LCD_DATA7, bit_test(n, 3));
004A: BCF 03.5
004B: BTFSC 2E.3
004C: GOTO 04F
004D: BCF 08.7
004E: GOTO 050
004F: BSF 08.7
0050: BSF 03.5
0051: BCF 08.7
.................... #else
.................... lcdlat.data = n;
.................... #endif
....................
.................... delay_cycles(1);
0052: NOP
.................... lcd_output_enable(1);
0053: BCF 03.5
0054: BSF 09.0
0055: BSF 03.5
0056: BCF 09.0
.................... delay_us(2);
0057: GOTO 058
0058: GOTO 059
.................... lcd_output_enable(0);
0059: BCF 03.5
005A: BCF 09.0
005B: BSF 03.5
005C: BCF 09.0
.................... }
005D: BCF 03.5
005E: 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.5
0091: 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.5
0095: BCF 09.1
0096: BSF 03.5
0097: BCF 09.1
.................... while ( bit_test(lcd_read_byte(),7) ) ;
*
00C6: MOVF 78,W
00C7: MOVWF 2D
00C8: BTFSS 2D.7
00C9: GOTO 0CC
00CA: BSF 03.5
00CB: GOTO 098
.................... lcd_output_rs(address);
00CC: MOVF 2B,F
00CD: BTFSS 03.2
00CE: GOTO 0D1
00CF: BCF 09.1
00D0: GOTO 0D2
00D1: BSF 09.1
00D2: BSF 03.5
00D3: BCF 09.1
.................... delay_cycles(1);
00D4: NOP
.................... lcd_output_rw(0);
00D5: BCF 03.5
00D6: BCF 09.2
00D7: BSF 03.5
00D8: BCF 09.2
.................... delay_cycles(1);
00D9: NOP
.................... lcd_output_enable(0);
00DA: BCF 03.5
00DB: BCF 09.0
00DC: BSF 03.5
00DD: BCF 09.0
.................... lcd_send_nibble(n >> 4);
00DE: BCF 03.5
00DF: SWAPF 2C,W
00E0: MOVWF 2D
00E1: MOVLW 0F
00E2: ANDWF 2D,F
00E3: MOVF 2D,W
00E4: MOVWF 2E
00E5: CALL 033
.................... lcd_send_nibble(n & 0xf);
00E6: MOVF 2C,W
00E7: ANDLW 0F
00E8: MOVWF 2D
00E9: MOVWF 2E
00EA: 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.5
00ED: 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.5
00F5: BCF 09.1
00F6: BSF 03.5
00F7: BCF 09.1
.................... lcd_output_rw(0);
00F8: BCF 03.5
00F9: BCF 09.2
00FA: BSF 03.5
00FB: BCF 09.2
.................... lcd_output_enable(0);
00FC: BCF 03.5
00FD: BCF 09.0
00FE: BSF 03.5
00FF: BCF 09.0
....................
.................... delay_ms(15);
0100: MOVLW 0F
0101: BCF 03.5
0102: MOVWF 27
0103: CALL 01F
.................... for(i=1;i<=3;++i)
0104: MOVLW 01
0105: MOVWF 23
0106: MOVF 23,W
0107: SUBLW 03
0108: BTFSS 03.0
0109: GOTO 112
.................... {
.................... lcd_send_nibble(3);
010A: MOVLW 03
010B: MOVWF 2E
010C: CALL 033
.................... delay_ms(5);
010D: MOVLW 05
010E: MOVWF 27
010F: CALL 01F
.................... }
0110: INCF 23,F
0111: GOTO 106
....................
.................... lcd_send_nibble(2);
0112: MOVLW 02
0113: MOVWF 2E
0114: CALL 033
.................... for(i=0;i<=3;++i)
0115: CLRF 23
0116: MOVF 23,W
0117: SUBLW 03
0118: BTFSS 03.0
0119: GOTO 123
.................... lcd_send_byte(0,LCD_INIT_STRING[i]);
011A: MOVF 23,W
011B: CALL 004
011C: MOVWF 24
011D: CLRF 2B
011E: MOVF 24,W
011F: MOVWF 2C
0120: CALL 090
....................
.................... #if defined(LCD_EXTENDED_NEWLINE)
0121: INCF 23,F
0122: 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,W
0125: GOTO 127
0126: GOTO 12A
.................... address=LCD_LINE_TWO;
0127: MOVLW 40
0128: MOVWF 29
.................... else
0129: GOTO 12B
.................... address=0;
012A: CLRF 29
....................
.................... address+=x-1;
012B: MOVLW 01
012C: SUBWF 27,W
012D: ADDWF 29,F
.................... lcd_send_byte(0,0x80|address);
012E: MOVF 29,W
012F: IORLW 80
0130: MOVWF 2A
0131: CLRF 2B
0132: MOVF 2A,W
0133: MOVWF 2C
0134: 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,W
0137: XORLW 07
0138: BTFSC 03.2
0139: GOTO 144
013A: XORLW 0B
013B: BTFSC 03.2
013C: GOTO 149
013D: XORLW 06
013E: BTFSC 03.2
013F: GOTO 151
0140: XORLW 02
0141: BTFSC 03.2
0142: GOTO 157
0143: GOTO 15C
.................... case '\a' : lcd_gotoxy(1,1); break;
0144: MOVLW 01
0145: MOVWF 27
0146: MOVWF 28
0147: CALL 124
0148: GOTO 162
....................
.................... case '\f' : lcd_send_byte(0,1);
0149: CLRF 2B
014A: MOVLW 01
014B: MOVWF 2C
014C: CALL 090
.................... delay_ms(2);
014D: MOVLW 02
014E: MOVWF 27
014F: 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 01
0152: MOVWF 27
0153: MOVLW 02
0154: MOVWF 28
0155: CALL 124
0156: GOTO 162
.................... #endif
....................
.................... case '\b' : lcd_send_byte(0,0x10); break;
0157: CLRF 2B
0158: MOVLW 10
0159: MOVWF 2C
015A: CALL 090
015B: 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 01
015D: MOVWF 2B
015E: MOVF 26,W
015F: MOVWF 2C
0160: CALL 090
0161: 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 23
01CE: MOVF 23,W
01CF: SUBLW 63
01D0: BTFSS 03.0
01D1: GOTO 1E2
.................... {
.................... output_low(BEEPER);
01D2: BSF 03.5
01D3: BCF 06.5
01D4: BCF 03.5
01D5: BCF 06.5
.................... delay_ms(1);
01D6: MOVLW 01
01D7: MOVWF 27
01D8: CALL 01F
.................... output_high(BEEPER);
01D9: BSF 03.5
01DA: BCF 06.5
01DB: BCF 03.5
01DC: BSF 06.5
.................... delay_ms(1);
01DD: MOVLW 01
01DE: MOVWF 27
01DF: CALL 01F
.................... }
01E0: INCF 23,F
01E1: GOTO 1CE
.................... }
01E2: BCF 0A.3
01E3: BCF 0A.4
01E4: GOTO 294 (RETURN)
....................
....................
.................... void main()
.................... {
01E5: CLRF 04
01E6: BCF 03.7
01E7: MOVLW 1F
01E8: ANDWF 03,F
01E9: MOVLW 71
01EA: BSF 03.5
01EB: MOVWF 0F
01EC: MOVF 0F,W
01ED: BSF 03.6
01EE: BCF 07.3
01EF: MOVLW 0C
01F0: BCF 03.6
01F1: MOVWF 19
01F2: MOVLW A2
01F3: MOVWF 18
01F4: MOVLW 90
01F5: BCF 03.5
01F6: MOVWF 18
01F7: BSF 03.5
01F8: BSF 03.6
01F9: MOVF 09,W
01FA: ANDLW C0
01FB: MOVWF 09
01FC: BCF 03.6
01FD: BCF 1F.4
01FE: BCF 1F.5
01FF: MOVLW 00
0200: BSF 03.6
0201: MOVWF 08
0202: BCF 03.5
0203: CLRF 07
0204: CLRF 08
0205: CLRF 09
*
0209: CLRF 22
020A: CLRF 21
.................... int16 i=0;
....................
.................... setup_adc_ports(NO_ANALOGS|VSS_VDD);
020B: BSF 03.5
020C: BSF 03.6
020D: MOVF 09,W
020E: ANDLW C0
020F: MOVWF 09
0210: BCF 03.6
0211: BCF 1F.4
0212: BCF 1F.5
0213: MOVLW 00
0214: BSF 03.6
0215: MOVWF 08
.................... setup_adc(ADC_CLOCK_DIV_2);
0216: BCF 03.5
0217: BCF 03.6
0218: BCF 1F.6
0219: BCF 1F.7
021A: BSF 03.5
021B: BSF 1F.7
021C: BCF 03.5
021D: BSF 1F.0
.................... setup_spi(SPI_SS_DISABLED);
021E: BCF 14.5
021F: BCF 20.5
0220: MOVF 20,W
0221: BSF 03.5
0222: MOVWF 07
0223: BCF 03.5
0224: BSF 20.4
0225: MOVF 20,W
0226: BSF 03.5
0227: MOVWF 07
0228: BCF 03.5
0229: BCF 20.3
022A: MOVF 20,W
022B: BSF 03.5
022C: MOVWF 07
022D: MOVLW 01
022E: BCF 03.5
022F: MOVWF 14
0230: MOVLW 00
0231: BSF 03.5
0232: MOVWF 14
.................... setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
0233: MOVF 01,W
0234: ANDLW C7
0235: IORLW 08
0236: MOVWF 01
.................... setup_timer_1(T1_DISABLED);
0237: BCF 03.5
0238: CLRF 10
.................... setup_timer_2(T2_DISABLED,0,1);
0239: MOVLW 00
023A: MOVWF 78
023B: MOVWF 12
023C: MOVLW 00
023D: BSF 03.5
023E: MOVWF 12
.................... setup_ccp1(CCP_OFF);
023F: BCF 03.5
0240: BSF 20.2
0241: MOVF 20,W
0242: BSF 03.5
0243: MOVWF 07
0244: BCF 03.5
0245: CLRF 17
0246: BSF 03.5
0247: CLRF 1B
0248: CLRF 1C
0249: MOVLW 01
024A: MOVWF 1D
.................... setup_comparator(NC_NC_NC_NC); // This device COMP currently not supported by the PICWizard
024B: BCF 03.5
024C: BSF 03.6
024D: CLRF 07
024E: CLRF 08
024F: CLRF 09
.................... setup_oscillator(OSC_8MHZ);
0250: MOVLW 71
0251: BSF 03.5
0252: BCF 03.6
0253: MOVWF 0F
0254: MOVF 0F,W
....................
.................... lcd_init();
0255: BCF 03.5
0256: CALL 0EC
.................... lcd_putc("(c) Kaklik 2013");
0257: MOVLW 0C
0258: BSF 03.6
0259: MOVWF 0D
025A: MOVLW 00
025B: MOVWF 0F
025C: BCF 03.6
025D: CALL 163
.................... lcd_gotoxy(3,2);
025E: MOVLW 03
025F: MOVWF 27
0260: MOVLW 02
0261: MOVWF 28
0262: CALL 124
.................... lcd_putc("www.mlab.cz");
0263: MOVLW 14
0264: BSF 03.6
0265: MOVWF 0D
0266: MOVLW 00
0267: MOVWF 0F
0268: BCF 03.6
0269: CALL 163
.................... Delay_ms(2000);
026A: MOVLW 08
026B: MOVWF 23
026C: MOVLW FA
026D: MOVWF 27
026E: CALL 01F
026F: DECFSZ 23,F
0270: GOTO 26C
.................... lcd_init();
0271: CALL 0EC
....................
.................... while (TRUE)
.................... {
.................... lcd_gotoxy(1,1);
0272: MOVLW 01
0273: MOVWF 27
0274: MOVWF 28
0275: CALL 124
....................
.................... printf(lcd_putc,"LCD test");
0276: MOVLW 1A
0277: BSF 03.6
0278: MOVWF 0D
0279: MOVLW 00
027A: MOVWF 0F
027B: BCF 03.6
027C: CALL 163
.................... lcd_gotoxy(1,2);
027D: MOVLW 01
027E: MOVWF 27
027F: MOVLW 02
0280: MOVWF 28
0281: CALL 124
.................... printf(lcd_putc,"%c %x ",i,i);
0282: MOVF 21,W
0283: MOVWF 26
0284: CALL 136
0285: MOVLW 20
0286: MOVWF 26
0287: CALL 136
0288: MOVF 21,W
0289: MOVWF 23
028A: MOVLW 57
028B: MOVWF 24
028C: GOTO 1A9
028D: MOVLW 20
028E: MOVWF 26
028F: CALL 136
.................... i++;
0290: INCF 21,F
0291: BTFSC 03.2
0292: INCF 22,F
.................... beep();
0293: GOTO 1CC
.................... Delay_ms(500);
0294: MOVLW 02
0295: MOVWF 23
0296: MOVLW FA
0297: MOVWF 27
0298: CALL 01F
0299: DECFSZ 23,F
029A: GOTO 296
.................... }
029B: GOTO 272
....................
.................... }
029C: SLEEP
Configuration Fuses:
Word 1: 2CF5 INTRC NOWDT NOPUT MCLR NOPROTECT NOCPD NOBROWNOUT IESO FCMEN NOLVP NODEBUG
Word 2: 3FFF NOWRT BORV40