Circuit Negma

C++, C, VB.NET, PCB, Electronics, Circuit Design

20×4 LCD :: Display Big Letters

Posted by Circuit Negma on December 27, 2009


Created By: Hussein Nosair

Description:

This project will attempt to accomplish the following:

1. Utilize the LCD abilities of creating Custom Character to build customized building blocks of the alphabets.

2. Utilize pre defined LCD characters.

3. Define every alphabet letter pattern using the customized building blocks. Each letter will consist of 12 building blocks, 3 blocks per line/row.

4. At this time, we will display a pre-coded message "HELLO" using 20×4 LCD. 20×4 LCD will only support 5 letters message at a time.           

Hardware:

1. uC : PIC18F4520 @ Microchip

2. External Clock (Oscillator) : 10MHz

3. Internal Clock (Oscillator) : 40MHz

4. LCD : 20×4 HDM20416L-1-YA0S

Software:

1. Editor IDE : MPLAB IDE v8.40

2. Compiler : MPLAB C18 v3.34

3. Internal clock is set to 4xPLL = 4x10MHz = 40MHz

Project:

We are going to start off by defining the headers/libraries needed in this project.

   1: /***********************************************************************/

   2: /*                      DEFINE THE LIBRARIES                           */

   3: /***********************************************************************/

   4: #include "Compiler.h"                           // Compiler configuration library

   5:                                                 // define which compiler headers to use

   6: #include "HardwareProfile.h"                    // Hardware configuration library

   7:                                                 // define Configuration bits of PIC18F uC

   8: //#include "GenericTypeDefs.h"                  // Global definition library

   9:                                                 // contains user Type definitions

  10: //#include "Global_Variables.h"                 // Global variables library

  11:                                                 // contains user defined global variables

  12: #include "LCD.h"                                // LCD library

  13:                                                 // contains functions related to operation of LCD

  14: //#include "keys_scan.h"                        // Keypad keys library

  15: //#include "sound.h"                            // Sound library

  16: //#include "Tick.h"                             // Ethernet (Clock) ticker library

Compiler.h

   1: /*********************************************************************

   2:  *

   3:  *                  Compiler and hardware specific definitions

   4:  *

   5:  *********************************************************************

   6:  * FileName:        Compiler.h

   7:  * Dependencies:    None

   8:  ********************************************************************/

   9: #ifndef __COMPILER_H

  10: #define __COMPILER_H

  11:  

  12: // Include proper device header file

  13: #if defined(__18CXX) || defined(HI_TECH_C)    

  14:     // All PIC18 processors

  15:     #if defined(HI_TECH_C)    // HI TECH PICC-18 compiler

  16:         #define __18CXX

  17:         #include <htc.h>

  18:     #else                    // Microchip C18 compiler

  19:         #include <p18cxxx.h>

  20:     #endif

  21: #elif defined(__PIC24F__)    // Microchip C30 compiler

  22:     // PIC24F processor

  23:     #include <p24Fxxxx.h>

  24: #elif defined(__PIC24H__)    // Microchip C30 compiler

  25:     // PIC24H processor

  26:     #include <p24Hxxxx.h>

  27: #elif defined(__dsPIC33F__)    // Microchip C30 compiler

  28:     // dsPIC33F processor

  29:     #include <p33Fxxxx.h>

  30: #elif defined(__dsPIC30F__)    // Microchip C30 compiler

  31:     // dsPIC30F processor

  32:     #include <p30fxxxx.h>

  33: #elif defined(__PIC32MX__)    // Microchip C32 compiler

  34:     #if !defined(__C32__)

  35:         #define __C32__

  36:     #endif

  37:     #include <p32xxxx.h>

  38:     #include <plib.h>

  39: #else

  40:     #error Unknown processor or compiler.  See Compiler.h

  41: #endif

  42:  

  43: #include <stdio.h>

  44: #include <stdlib.h>

  45: #include <string.h>

  46:  

  47:  

  48: // Base RAM and ROM pointer types for given architecture

  49: #if defined(__C32__)

  50:     #define PTR_BASE        DWORD

  51:     #define ROM_PTR_BASE    DWORD

  52: #elif defined(__C30__)

  53:     #define PTR_BASE        WORD

  54:     #define ROM_PTR_BASE    WORD

  55: #elif defined(__18CXX)

  56:     #define PTR_BASE        WORD

  57:     #define ROM_PTR_BASE    unsigned short long

  58: #endif

  59:  

  60:  

  61: // Definitions that apply to all compilers, except C18

  62: #if !defined(__18CXX) || defined(HI_TECH_C)

  63:     #define memcmppgm2ram(a,b,c)    memcmp(a,b,c)

  64:     #define strcmppgm2ram(a,b)        strcmp(a,b)

  65:     #define memcpypgm2ram(a,b,c)    memcpy(a,b,c)

  66:     #define strcpypgm2ram(a,b)        strcpy(a,b)

  67:     #define strncpypgm2ram(a,b,c)    strncpy(a,b,c)

  68:     #define strstrrampgm(a,b)        strstr(a,b)

  69:     #define    strlenpgm(a)            strlen(a)

  70:     #define strchrpgm(a,b)            strchr(a,b)

  71:     #define strcatpgm2ram(a,b)        strcat(a,b)

  72: #endif

  73:  

  74:  

  75: // Definitions that apply to all 8-bit products

  76: // (PIC18)

  77: #if defined(__18CXX)

  78:     #define    __attribute__(a)

  79:  

  80:     #define FAR                         far

  81:  

  82:     // Microchip C18 specific defines

  83:     #if !defined(HI_TECH_C)

  84:         #define ROM                     rom

  85:         #define strcpypgm2ram(a, b)        strcpypgm2ram(a,(far rom char*)b)

  86:     #endif

  87:     

  88:     // HI TECH PICC-18 STD specific defines

  89:     #if defined(HI_TECH_C)

  90:         #define ROM                     const

  91:         #define rom

  92:         #define Nop()                   asm("NOP");

  93:         #define ClrWdt()                asm("CLRWDT");

  94:         #define Reset()                    asm("RESET");

  95:     #endif

  96:     

  97: // Definitions that apply to all 16-bit and 32-bit products

  98: // (PIC24F, PIC24H, dsPIC30F, dsPIC33F, and PIC32)

  99: #else

 100:     #define    ROM                        const

 101:  

 102:     // 16-bit specific defines (PIC24F, PIC24H, dsPIC30F, dsPIC33F)

 103:     #if defined(__C30__)

 104:         #define Reset()                asm("reset")

 105:         #define FAR                 __attribute__((far))

 106:     #endif

 107:  

 108:     // 32-bit specific defines (PIC32)

 109:     #if defined(__C32__)

 110:         #define persistent

 111:         #define far

 112:         #define FAR

 113:         #define Reset()                SoftReset()

 114:         #define ClrWdt()            (WDTCONSET = _WDTCON_WDTCLR_MASK)

 115:         #define Nop()                asm("nop")

 116:     #endif

 117: #endif

 118:  

 119:  

 120:  

 121: #endif

 

HardwareProfile.h

   1: /*********************************************************************

   2:  *

   3:  *    Hardware specific definitions

   4:  *

   5:  *********************************************************************

   6:  * FileName:        HardwareProfile.h

   7:  * Dependencies:    None

   8:  ********************************************************************/

   9: #ifndef __HARDWARE_PROFILE_H

  10: #define __HARDWARE_PROFILE_H

  11:  

  12: #include "Compiler.h"

  13:  

  14:  

  15: // Choose which hardware profile to compile for here.  See 

  16: // the hardware profiles below for meaning of various options.  

  17: #define PICDEMNET2

  18:  

  19: // If no hardware profiles are defined, assume that we are using 

  20: // a Microchip demo board and try to auto-select the correct profile

  21: // based on processor selected in MPLAB

  22: #if !defined(PICDEMNET2) && !defined(HPC_EXPLORER) && !defined(PICDEMZ) && !defined(EXPLORER_16) && !defined(PIC24FJ64GA004_PIM) && !defined(DSPICDEM11) && !defined(PICDEMNET2) && !defined(INTERNET_RADIO) && !defined(YOUR_BOARD)

  23:     #if defined(__18F97J60) || defined(_18F97J60) || defined(__18F4520)

  24:         #define PICDEMNET2

  25:     #endif

  26: #endif

  27:  

  28: // Set configuration fuses (but only once)

  29: #if defined(THIS_IS_STACK_APPLICATION)

  30:     #if defined(__18CXX)

  31:         #if defined(__EXTENDED18__)

  32:             #pragma config XINST=ON

  33:         #elif !defined(HI_TECH_C)

  34:             #pragma config XINST=OFF

  35:         #endif

  36:     

  37:         if defined(__18F4520) || defined(__18F452)    

  38:             // STANLY KEYPAD

  39:             #pragma config OSC = HSPLL, FCMEN = ON, IESO = ON

  40:             #pragma config PWRT = OFF, BOREN = ON, BORV = 1

  41:             #pragma config WDT = OFF, WDTPS = 2048

  42:             #pragma config MCLRE = ON, LPT1OSC = OFF, PBADEN = OFF, CCP2MX = PORTC

  43:             #pragma config STVREN = ON, LVP = OFF

  44:         #endif

  45:     #endif

  46: #endif // Prevent more than one set of config fuse definitions

  47:  

  48: // Clock frequency value.

  49: // This value is used to calculate Tick Counter value

  50: #if defined(__18CXX)

  51:     // All PIC18 processors

  52:     #if defined(PICDEMNET2) || defined(INTERNET_RADIO)

  53:         #if defined(__18F97J60)

  54:             #define GetSystemClock()        (41666667ul)      // Hz

  55:         #else

  56:             #define GetSystemClock()        (40000000ul)

  57:         #endif        

  58:         #define GetInstructionClock()    (GetSystemClock()/4)

  59:         #define GetPeripheralClock()    GetInstructionClock()

  60:     #else

  61:         #define GetSystemClock()        (40000000ul)      // Hz

  62:         #define GetInstructionClock()    (GetSystemClock()/4)

  63:         #define GetPeripheralClock()    GetInstructionClock()

  64:     #endif

  65: #endif

  66:  

  67: // Hardware mappings

  68: #if defined(PICDEMNET2) && !defined(HI_TECH_C)

  69: // PICDEM.net 2 (PIC18F97J60 + ENC28J60)

  70:       

  71:     //Define Backlit keys, Speaker and RS-485 ports

  72:     #define LED_IO      LATCbits.LATC1              // Define RC1 to be LED port   

  73:     #define LED_TRIS    TRISCbits.TRISC1    

  74:     #define LED_GET()            (LATC)

  75:     #define LED_PUT(a)            (LATC = (a))

  76:  

  77:     // LCD I/O pins

  78:     #define LCD_DATA_TRIS        (TRISD)

  79:     #define LCD_DATA_IO            (LATD)

  80:  

  81:     #define LCD_RD_WR_TRIS        (TRISEbits.TRISE2)

  82:     #define LCD_RD_WR_IO        (LATEbits.LATE2)

  83:     #define LCD_RS_TRIS            (TRISEbits.TRISE0)

  84:     #define LCD_RS_IO            (LATEbits.LATE0)

  85:     #define LCD_E_TRIS            (TRISEbits.TRISE1)

  86:     #define LCD_E_IO            (LATEbits.LATE1)

  87:  

  88: #else

  89:     #error "Hardware profile not defined.  See available profiles in HardwareProfile.h.  Add the appropriate macro definition to your application configuration file ('TCPIPConfig.h', etc.)"

  90: #endif

  91:  

  92:  

  93: #if defined(__18CXX)    // PIC18

  94:     // UART mapping functions for consistent API names across 8-bit and 16 or 

  95:     // 32 bit compilers.  For simplicity, everything will use "UART" instead 

  96:     // of USART/EUSART/etc.

  97:     #define BusyUART()                BusyUSART()

  98:     #define CloseUART()                CloseUSART()

  99:     #define ConfigIntUART(a)        ConfigIntUSART(a)

 100:     #define DataRdyUART()            DataRdyUSART()

 101:     #define OpenUART(a,b,c)            OpenUSART(a,b,c)

 102:     #define ReadUART()                ReadUSART()

 103:     #define WriteUART(a)            WriteUSART(a)

 104:     #define getsUART(a,b,c)            getsUSART(b,a)

 105:     #define putsUART(a)                putsUSART(a)

 106:     #define getcUART()                ReadUSART()

 107:     #define putcUART(a)                WriteUSART(a)

 108:     #define putrsUART(a)            putrsUSART((far rom char*)a)

 109:  

 110: #endif

 111:  

 112:  

 113: #endif

 

LCD.h

Sorry, I cannot post this file, however, it is not that complicated. you could search the internet (google) for LCD library and tweak it to meet you hardware configuration

Now that we are done with include files, we are going to define some global variables, definitions and functions Decleration:

   1: /***********************************************************************/

   2: /*                     DEFINE STATIC VARIABLES                         */

   3: /***********************************************************************/

   4: #define TIMER1_LED_DELAY        2               // LED Timeout = 2*1.67sec

   5:  

   6: #define EMPTY_BLOCK_PATTERN        0xFE            // Pre-defined pattern by LCD

   7: #define FULL_BLOCK_PATTERN        0xFF            // Pre-defined pattern by LCD

   8:  

   9:  

  10: /***********************************************************************/

  11: /*                     DEFINE GLOBAL VARIABLES                         */

  12: /***********************************************************************/

  13: unsigned char LEDTime;                          // Define LED timout

  14: //unsigned char dwInternalTicks;                // Define Ethernet tick counter

  15:  

  16: // Define customized building blocks of alphabets letters.

  17: //---------------------------------------------------------

  18: const unsigned char aShapes[8][8] = { {0 , 0 , 0 , 1 , 3 , 7 , 15 , 31},        // Patter 1 saved to LCD RAM @ 0

  19:                                          {0 , 0 , 0 , 16 , 24 , 28 , 30 , 31},        // Patter 2 saved to LCD RAM @ 1

  20:                                          {31 , 15 , 7 , 3 , 1 , 0 , 0 , 0},        // Patter 3 saved to LCD RAM @ 2

  21:                                          {31 , 30 , 28 , 24 , 16 , 0 , 0 , 0},        // Patter 4 saved to LCD RAM @ 3

  22:                                          {0 , 0 , 0 , 31 , 31 , 31 , 31 , 31},        // Patter 5 saved to LCD RAM @ 4

  23:                                          {31 , 31 , 31 , 31 , 31 , 0 , 0 , 0},        // Patter 6 saved to LCD RAM @ 5

  24:                                          {31 , 31 , 31 , 30 , 28 , 24 , 16 , 0},    // Patter 7 saved to LCD RAM @ 6

  25:                                          {0 , 16 , 24 , 28 , 30 , 31 , 31 , 31}    // Patter 8 saved to LCD RAM @ 7

  26:                                     };

  27:  

  28: // Define message of 5 letters to be displayed on the LCD

  29: //---------------------------------------------------------                                

  30: unsigned char aText[6] = "HELLO";

  31:  

  32: unsigned char *paText;                            // Define the letter to be displayed

  33: unsigned char xPos;                                // Define the LCD cursor location

  34:  

  35:  

  36: /***********************************************************************/

  37: /*                     DEFINE PRIVATE SUBROUTINES                      */

  38: /***********************************************************************/

  39: // Define Board's hardware initialization subroutine

  40: //----------------------------------------------------

  41: void InitializeBoard(void);                     

  42:  

  43: // Define letters of alphabets patters

  44: //----------------------------------------------------

  45: void DrawCharacter(unsigned char *pStr, unsigned char *pxPos);

  46:  

  47:  

 

Functions Definitions:

   1: /********************************************************************

   2: *       Function Name:  InitializeBoard                             *

   3: *       Return Value:   None                                        *

   4: *       Parameters:     void                                        *

   5: *       Description:    This routine initialize the on board's      *

   6: *                       modules and microprocessor.                 *

   7: ********************************************************************/

   8: void InitializeBoard(void)

   9: {

  10:     RCON    = 0x80;

  11:     INTCON  = 0xE0;

  12:     INTCON2 = 0x84;

  13:     INTCON3 = 0x00;

  14:     

  15:     #if defined(__18F97J60)

  16:         PIR1 = 0x00;

  17:         PIR2 = 0x00;

  18:         PIR3 = 0x00;

  19:         PIE1 = 0x00;

  20:         PIE2 = 0x00;

  21:         PIE3 = 0x00;

  22:         LATA = 0xC0;

  23:     #endif

  24:     

  25:     // Initiailize Digital Pins

  26:     //----------------------------

  27:     ADCON1 = 0x0F;              // Analog pins to digital

  28:     CMCON = 0x00; //0xCF;

  29:     CVRCON = 0x00;

  30:     

  31:     #if defined(__18F97J60)

  32:         PORTAbits.RJPU = 0;

  33:     #endif

  34:  

  35:     // Enable internal PORTB pull-ups

  36:     //----------------------------

  37:     INTCON2bits.RBPU = 1;

  38:     

  39:     // Enable Interrupts

  40:     //----------------------------

  41:     RCONbits.IPEN = 1;            // Enable interrupt priorities

  42:     INTCONbits.GIEH = 1;

  43:     INTCONbits.GIEL = 1;

  44:  

  45:     // Set Internal Oscillator/Clock

  46:     //----------------------------

  47:     OSCTUNE = 0x00;             //<-----------

  48:     

  49:     // Initialize LEDs

  50:     //--------------------------

  51:     LED_TRIS = 0;

  52:     LED_IO = 0;

  53:  

  54:     // Initialize LCD

  55:     //--------------------------

  56:     LCD_DATA_TRIS = 0x0F;   // Set Data Bus Direction to output

  57:     LCD_RD_WR_TRIS  = 0;    // Set R/W pin direction to output

  58:     LCD_RS_TRIS     = 0;    // Set Reset pin direction to output

  59:     LCD_E_TRIS      = 0;    // Set Enable pin direction to output

  60:     DelayMs(50);            // wait for 15ms to allow the voltage to  rise to moe than 4.5V

  61:     LCDInit();

  62:     

  63:     // Initialize KEYs

  64: //    Keys_init();

  65:     

  66:     // Initialize Speaker

  67: //    BUZZER_TRIS = 0;

  68: //    BUZZER = 0;

  69:  

  70:     // Initialize Timer 0

  71:     //--------------------------

  72:     // Use Timer0 for 8 bit processors

  73:     // Initialize the time

  74:     TMR0H = 0;

  75:     TMR0L = 0;

  76:  

  77:     // Set up the timer interrupt

  78:     INTCON2bits.TMR0IP = 0;        // Low priority

  79:     INTCONbits.TMR0IF = 0;

  80:     INTCONbits.TMR0IE = 1;        // Enable interrupt

  81:  

  82:     // Timer0 on, 16-bit, internal timer, 1:256 prescalar

  83:     T0CON = 0x87;

  84:  

  85:  

  86:     // Start Clock

  87: //    TickInit();    

  88: }

  89:  

  90: /********************************************************************

  91: *       Function Name:  DrawCharacter                                *

  92: *       Return Value:   None                                        *

  93: *       Parameters:     letter pointer, cursor location pointer     *

  94: *       Description:    This routine will display the capital       *

  95: *                       letter of characters defined in the message *

  96: ********************************************************************/

  97: void DrawCharacter(unsigned char *pStr, unsigned char *pxPos)

  98: {

  99:         if(*pStr == 'a' || *pStr == 'A')

 100:         {

 101:             LCD_Move(1, *pxPos);

 102:             LCDReadCustomChar(0);

 103:             LCDReadCustomChar(4);

 104:             LCDReadCustomChar(1);

 105:  

 106:             LCD_Move(2, *pxPos);

 107:             LCDWriteData(FULL_BLOCK_PATTERN);

 108:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 109:             LCDWriteData(FULL_BLOCK_PATTERN);

 110:  

 111:             LCD_Move(3, *pxPos);

 112:             LCDWriteData(FULL_BLOCK_PATTERN);

 113:             LCDReadCustomChar(5);

 114:             LCDWriteData(FULL_BLOCK_PATTERN);

 115:  

 116:             LCD_Move(4, *pxPos);

 117:             LCDReadCustomChar(5);

 118:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 119:             LCDReadCustomChar(5);

 120:             

 121:             return;

 122:         }    

 123:         else if(*pStr == 'b' || *pStr == 'B')

 124:         {

 125:             LCD_Move(1, *pxPos);

 126:             LCDReadCustomChar(4);

 127:             LCDReadCustomChar(4);

 128:             LCDReadCustomChar(1);

 129:  

 130:             LCD_Move(2, *pxPos);

 131:             LCDWriteData(FULL_BLOCK_PATTERN);

 132:             LCDReadCustomChar(0);

 133:             LCDReadCustomChar(6);

 134:  

 135:             LCD_Move(3, *pxPos);

 136:             LCDWriteData(FULL_BLOCK_PATTERN);

 137:             LCDReadCustomChar(2);

 138:             LCDReadCustomChar(7);

 139:  

 140:             LCD_Move(4, *pxPos);

 141:             LCDReadCustomChar(5);

 142:             LCDReadCustomChar(5);

 143:             LCDReadCustomChar(3);

 144:             

 145:             return;

 146:         }    

 147:         else if(*pStr == 'c' || *pStr == 'C')

 148:         {

 149:             LCD_Move(1, *pxPos);

 150:             LCDReadCustomChar(0);

 151:             LCDReadCustomChar(4);

 152:             LCDReadCustomChar(1);

 153:  

 154:             LCD_Move(2, *pxPos);

 155:             LCDWriteData(FULL_BLOCK_PATTERN);

 156:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 157:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 158:  

 159:             LCD_Move(3, *pxPos);

 160:             LCDWriteData(FULL_BLOCK_PATTERN);

 161:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 162:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 163:  

 164:             LCD_Move(4, *pxPos);

 165:             LCDReadCustomChar(2);

 166:             LCDReadCustomChar(5);

 167:             LCDReadCustomChar(3);

 168:             

 169:             return;

 170:         }    

 171:         else if(*pStr == 'd' || *pStr == 'D')

 172:         {

 173:             LCD_Move(1, *pxPos);

 174:             LCDReadCustomChar(4);

 175:             LCDReadCustomChar(4);

 176:             LCDReadCustomChar(1);

 177:  

 178:             LCD_Move(2, *pxPos);

 179:             LCDWriteData(FULL_BLOCK_PATTERN);

 180:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 181:             LCDWriteData(FULL_BLOCK_PATTERN);

 182:  

 183:             LCD_Move(3, *pxPos);

 184:             LCDWriteData(FULL_BLOCK_PATTERN);

 185:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 186:             LCDWriteData(FULL_BLOCK_PATTERN);

 187:  

 188:             LCD_Move(4, *pxPos);

 189:             LCDReadCustomChar(5);

 190:             LCDReadCustomChar(5);

 191:             LCDReadCustomChar(3);

 192:             

 193:             return;

 194:         }    

 195:         else if(*pStr == 'e' || *pStr == 'E')

 196:         {

 197:             LCD_Move(1, *pxPos);

 198:             LCDReadCustomChar(4);

 199:             LCDReadCustomChar(4);

 200:             LCDReadCustomChar(4);

 201:  

 202:             LCD_Move(2, *pxPos);

 203:             LCDWriteData(FULL_BLOCK_PATTERN);

 204:             LCDReadCustomChar(4);

 205:             LCDReadCustomChar(4);

 206:  

 207:             LCD_Move(3, *pxPos);

 208:             LCDWriteData(FULL_BLOCK_PATTERN);

 209:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 210:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 211:  

 212:             LCD_Move(4, *pxPos);

 213:             LCDReadCustomChar(5);

 214:             LCDReadCustomChar(5);

 215:             LCDReadCustomChar(5);

 216:             

 217:             return;

 218:         }    

 219:         else if(*pStr == 'f' || *pStr == 'F')

 220:         {

 221:             LCD_Move(1, *pxPos);

 222:             LCDReadCustomChar(4);

 223:             LCDReadCustomChar(4);

 224:             LCDReadCustomChar(4);

 225:  

 226:             LCD_Move(2, *pxPos);

 227:             LCDWriteData(FULL_BLOCK_PATTERN);

 228:             LCDReadCustomChar(4);

 229:             LCDReadCustomChar(4);

 230:  

 231:             LCD_Move(3, *pxPos);

 232:             LCDWriteData(FULL_BLOCK_PATTERN);

 233:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 234:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 235:  

 236:             LCD_Move(4, *pxPos);

 237:             LCDReadCustomChar(5);

 238:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 239:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 240:             

 241:             return;

 242:         }    

 243:         else if(*pStr == 'g' || *pStr == 'G')

 244:         {

 245:             LCD_Move(1, *pxPos);

 246:             LCDReadCustomChar(0);

 247:             LCDReadCustomChar(4);

 248:             LCDReadCustomChar(1);

 249:  

 250:             LCD_Move(2, *pxPos);

 251:             LCDWriteData(FULL_BLOCK_PATTERN);

 252:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 253:             LCDReadCustomChar(5);

 254:  

 255:             LCD_Move(3, *pxPos);

 256:             LCDWriteData(FULL_BLOCK_PATTERN);

 257:             LCDReadCustomChar(5);

 258:             LCDWriteData(FULL_BLOCK_PATTERN);

 259:  

 260:             LCD_Move(4, *pxPos);

 261:             LCDReadCustomChar(2);

 262:             LCDReadCustomChar(5);

 263:             LCDReadCustomChar(3);

 264:             

 265:             return;

 266:         }    

 267:         else if(*pStr == 'h' || *pStr == 'H')

 268:         {

 269:             LCD_Move(1, *pxPos);

 270:             LCDReadCustomChar(4);

 271:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 272:             LCDReadCustomChar(4);

 273:  

 274:             LCD_Move(2, *pxPos);

 275:             LCDWriteData(FULL_BLOCK_PATTERN);

 276:             LCDReadCustomChar(4);

 277:             LCDWriteData(FULL_BLOCK_PATTERN);

 278:  

 279:             LCD_Move(3, *pxPos);

 280:             LCDWriteData(FULL_BLOCK_PATTERN);

 281:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 282:             LCDWriteData(FULL_BLOCK_PATTERN);

 283:  

 284:             LCD_Move(4, *pxPos);

 285:             LCDReadCustomChar(5);

 286:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 287:             LCDReadCustomChar(5);

 288:             

 289:             return;

 290:         }    

 291:         else if(*pStr == 'i' || *pStr == 'I')

 292:         {

 293:             LCD_Move(1, *pxPos);

 294:             LCDReadCustomChar(4);

 295:             LCDReadCustomChar(4);

 296:             LCDReadCustomChar(4);

 297:  

 298:             LCD_Move(2, *pxPos);

 299:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 300:             LCDWriteData(FULL_BLOCK_PATTERN);

 301:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 302:  

 303:             LCD_Move(3, *pxPos);

 304:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 305:             LCDWriteData(FULL_BLOCK_PATTERN);

 306:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 307:  

 308:             LCD_Move(4, *pxPos);

 309:             LCDReadCustomChar(5);

 310:             LCDReadCustomChar(5);

 311:             LCDReadCustomChar(5);

 312:             

 313:             return;

 314:         }    

 315:         else if(*pStr == 'j' || *pStr == 'J')

 316:         {

 317:             LCD_Move(1, *pxPos);

 318:             LCDReadCustomChar(4);

 319:             LCDReadCustomChar(4);

 320:             LCDReadCustomChar(4);

 321:  

 322:             LCD_Move(2, *pxPos);

 323:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 324:             LCDWriteData(FULL_BLOCK_PATTERN);

 325:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 326:  

 327:             LCD_Move(3, *pxPos);

 328:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 329:             LCDWriteData(FULL_BLOCK_PATTERN);

 330:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 331:  

 332:             LCD_Move(4, *pxPos);

 333:             LCDReadCustomChar(5);

 334:             LCDReadCustomChar(3);

 335:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 336:             

 337:             return;

 338:         }    

 339:         else if(*pStr == 'k' || *pStr == 'K')

 340:         {

 341:             LCD_Move(1, *pxPos);

 342:             LCDReadCustomChar(4);

 343:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 344:             LCDReadCustomChar(4);

 345:  

 346:             LCD_Move(2, *pxPos);

 347:             LCDWriteData(FULL_BLOCK_PATTERN);

 348:             LCDReadCustomChar(0);

 349:             LCDReadCustomChar(6);

 350:  

 351:             LCD_Move(3, *pxPos);

 352:             LCDWriteData(FULL_BLOCK_PATTERN);

 353:             LCDReadCustomChar(2);

 354:             LCDReadCustomChar(7);

 355:  

 356:             LCD_Move(4, *pxPos);

 357:             LCDReadCustomChar(5);

 358:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 359:             LCDReadCustomChar(5);

 360:             

 361:             return;

 362:         }    

 363:         else if(*pStr == 'l' || *pStr == 'L')

 364:         {

 365:             LCD_Move(1, *pxPos);

 366:             LCDReadCustomChar(4);

 367:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 368:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 369:  

 370:             LCD_Move(2, *pxPos);

 371:             LCDWriteData(FULL_BLOCK_PATTERN);

 372:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 373:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 374:  

 375:             LCD_Move(3, *pxPos);

 376:             LCDWriteData(FULL_BLOCK_PATTERN);

 377:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 378:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 379:  

 380:             LCD_Move(4, *pxPos);

 381:             LCDReadCustomChar(5);

 382:             LCDReadCustomChar(5);

 383:             LCDReadCustomChar(5);

 384:             

 385:             return;

 386:         }    

 387:         else if(*pStr == 'm' || *pStr == 'M')

 388:         {

 389:             LCD_Move(1, *pxPos);

 390:             LCDReadCustomChar(1);

 391:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 392:             LCDReadCustomChar(0);

 393:  

 394:             LCD_Move(2, *pxPos);

 395:             LCDWriteData(FULL_BLOCK_PATTERN);

 396:             LCDWriteData(FULL_BLOCK_PATTERN);

 397:             LCDWriteData(FULL_BLOCK_PATTERN);

 398:  

 399:             LCD_Move(3, *pxPos);

 400:             LCDWriteData(FULL_BLOCK_PATTERN);

 401:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 402:             LCDWriteData(FULL_BLOCK_PATTERN);

 403:  

 404:             LCD_Move(4, *pxPos);

 405:             LCDReadCustomChar(5);

 406:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 407:             LCDReadCustomChar(5);

 408:             

 409:             return;

 410:         }    

 411:         else if(*pStr == 'n' || *pStr == 'N')

 412:         {

 413:             LCD_Move(1, *pxPos);

 414:             LCDReadCustomChar(4);

 415:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 416:             LCDReadCustomChar(4);

 417:  

 418:             LCD_Move(2, *pxPos);

 419:             LCDWriteData(FULL_BLOCK_PATTERN);

 420:             LCDReadCustomChar(7);

 421:             LCDWriteData(FULL_BLOCK_PATTERN);

 422:  

 423:             LCD_Move(3, *pxPos);

 424:             LCDWriteData(FULL_BLOCK_PATTERN);

 425:             LCDReadCustomChar(2);

 426:             LCDWriteData(FULL_BLOCK_PATTERN);

 427:  

 428:             LCD_Move(4, *pxPos);

 429:             LCDReadCustomChar(5);

 430:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 431:             LCDReadCustomChar(5);

 432:             

 433:             return;

 434:         }    

 435:         else if(*pStr == 'o' || *pStr == 'O')

 436:         {

 437:             LCD_Move(1, *pxPos);

 438:             LCDReadCustomChar(0);

 439:             LCDReadCustomChar(4);

 440:             LCDReadCustomChar(1);

 441:  

 442:             LCD_Move(2, *pxPos);

 443:             LCDWriteData(FULL_BLOCK_PATTERN);

 444:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 445:             LCDWriteData(FULL_BLOCK_PATTERN);

 446:  

 447:             LCD_Move(3, *pxPos);

 448:             LCDWriteData(FULL_BLOCK_PATTERN);

 449:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 450:             LCDWriteData(FULL_BLOCK_PATTERN);

 451:  

 452:             LCD_Move(4, *pxPos);

 453:             LCDReadCustomChar(2);

 454:             LCDReadCustomChar(5);

 455:             LCDReadCustomChar(3);

 456:             

 457:             return;

 458:         }    

 459:         else if(*pStr == 'p' || *pStr == 'P')

 460:         {

 461:             LCD_Move(1, *pxPos);

 462:             LCDReadCustomChar(4);

 463:             LCDReadCustomChar(4);

 464:             LCDReadCustomChar(1);

 465:  

 466:             LCD_Move(2, *pxPos);

 467:             LCDWriteData(FULL_BLOCK_PATTERN);

 468:             LCDReadCustomChar(4);

 469:             LCDReadCustomChar(6);

 470:  

 471:             LCD_Move(3, *pxPos);

 472:             LCDWriteData(FULL_BLOCK_PATTERN);

 473:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 474:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 475:  

 476:             LCD_Move(4, *pxPos);

 477:             LCDReadCustomChar(5);

 478:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 479:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 480:             

 481:             return;

 482:         }    

 483:         else if(*pStr == 'q' || *pStr == 'Q')

 484:         {

 485:             LCD_Move(1, *pxPos);

 486:             LCDReadCustomChar(0);

 487:             LCDReadCustomChar(4);

 488:             LCDReadCustomChar(1);

 489:  

 490:             LCD_Move(2, *pxPos);

 491:             LCDWriteData(FULL_BLOCK_PATTERN);

 492:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 493:             LCDWriteData(FULL_BLOCK_PATTERN);

 494:  

 495:             LCD_Move(3, *pxPos);

 496:             LCDWriteData(FULL_BLOCK_PATTERN);

 497:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 498:             LCDWriteData(FULL_BLOCK_PATTERN);

 499:  

 500:             LCD_Move(4, *pxPos);

 501:             LCDReadCustomChar(2);

 502:             LCDReadCustomChar(5);

 503:             LCDWriteData(FULL_BLOCK_PATTERN);

 504:             

 505:             return;

 506:         }    

 507:         else if(*pStr == 'r' || *pStr == 'R')

 508:         {

 509:             LCD_Move(1, *pxPos);

 510:             LCDReadCustomChar(4);

 511:             LCDReadCustomChar(4);

 512:             LCDReadCustomChar(1);

 513:  

 514:             LCD_Move(2, *pxPos);

 515:             LCDWriteData(FULL_BLOCK_PATTERN);

 516:             LCDReadCustomChar(0);

 517:             LCDReadCustomChar(6);

 518:  

 519:             LCD_Move(3, *pxPos);

 520:             LCDWriteData(FULL_BLOCK_PATTERN);

 521:             LCDReadCustomChar(2);

 522:             LCDReadCustomChar(7);

 523:  

 524:             LCD_Move(4, *pxPos);

 525:             LCDReadCustomChar(5);

 526:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 527:             LCDReadCustomChar(5);

 528:             

 529:             return;

 530:         }    

 531:         else if(*pStr == 's' || *pStr == 'S')

 532:         {

 533:             LCD_Move(1, *pxPos);

 534:             LCDReadCustomChar(0);

 535:             LCDReadCustomChar(4);

 536:             LCDReadCustomChar(1);

 537:  

 538:             LCD_Move(2, *pxPos);

 539:             LCDWriteData(FULL_BLOCK_PATTERN);

 540:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 541:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 542:  

 543:             LCD_Move(3, *pxPos);

 544:             LCDReadCustomChar(2);

 545:             LCDReadCustomChar(5);

 546:             LCDReadCustomChar(7);

 547:  

 548:             LCD_Move(4, *pxPos);

 549:             LCDReadCustomChar(2);

 550:             LCDReadCustomChar(5);

 551:             LCDReadCustomChar(3);

 552:             

 553:             return;

 554:         }    

 555:         else if(*pStr == 't' || *pStr == 'T')

 556:         {

 557:             LCD_Move(1, *pxPos);

 558:             LCDReadCustomChar(4);

 559:             LCDReadCustomChar(4);

 560:             LCDReadCustomChar(4);

 561:  

 562:             LCD_Move(2, *pxPos);

 563:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 564:             LCDWriteData(FULL_BLOCK_PATTERN);

 565:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 566:  

 567:             LCD_Move(3, *pxPos);

 568:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 569:             LCDWriteData(FULL_BLOCK_PATTERN);

 570:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 571:  

 572:             LCD_Move(4, *pxPos);

 573:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 574:             LCDReadCustomChar(5);

 575:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 576:             

 577:             return;

 578:         }    

 579:         else if(*pStr == 'u' || *pStr == 'U')

 580:         {

 581:             LCD_Move(1, *pxPos);

 582:             LCDReadCustomChar(4);

 583:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 584:             LCDReadCustomChar(4);

 585:  

 586:             LCD_Move(2, *pxPos);

 587:             LCDWriteData(FULL_BLOCK_PATTERN);

 588:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 589:             LCDWriteData(FULL_BLOCK_PATTERN);

 590:  

 591:             LCD_Move(3, *pxPos);

 592:             LCDWriteData(FULL_BLOCK_PATTERN);

 593:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 594:             LCDWriteData(FULL_BLOCK_PATTERN);

 595:  

 596:             LCD_Move(4, *pxPos);

 597:             LCDReadCustomChar(2);

 598:             LCDReadCustomChar(5);

 599:             LCDReadCustomChar(3);

 600:             

 601:             return;

 602:         }    

 603:         else if(*pStr == 'v' || *pStr == 'V')

 604:         {

 605:             LCD_Move(1, *pxPos);

 606:             LCDReadCustomChar(4);

 607:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 608:             LCDReadCustomChar(4);

 609:  

 610:             LCD_Move(2, *pxPos);

 611:             LCDWriteData(FULL_BLOCK_PATTERN);

 612:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 613:             LCDWriteData(FULL_BLOCK_PATTERN);

 614:  

 615:             LCD_Move(3, *pxPos);

 616:             LCDWriteData(FULL_BLOCK_PATTERN);

 617:             LCDReadCustomChar(0);

 618:             LCDReadCustomChar(6);

 619:  

 620:             LCD_Move(4, *pxPos);

 621:             LCDReadCustomChar(2);

 622:             LCDReadCustomChar(3);

 623:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 624:             

 625:             return;

 626:         }    

 627:         else if(*pStr == 'w' || *pStr == 'W')

 628:         {

 629:             LCD_Move(1, *pxPos);

 630:             LCDReadCustomChar(4);

 631:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 632:             LCDReadCustomChar(4);

 633:  

 634:             LCD_Move(2, *pxPos);

 635:             LCDWriteData(FULL_BLOCK_PATTERN);

 636:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 637:             LCDWriteData(FULL_BLOCK_PATTERN);

 638:  

 639:             LCD_Move(3, *pxPos);

 640:             LCDWriteData(FULL_BLOCK_PATTERN);

 641:             LCDWriteData(FULL_BLOCK_PATTERN);

 642:             LCDWriteData(FULL_BLOCK_PATTERN);

 643:  

 644:             LCD_Move(4, *pxPos);

 645:             LCDReadCustomChar(3);

 646:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 647:             LCDReadCustomChar(2);

 648:             

 649:             return;

 650:         }    

 651:         else if(*pStr == 'x' || *pStr == 'X')

 652:         {

 653:             LCD_Move(1, *pxPos);

 654:             LCDReadCustomChar(4);

 655:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 656:             LCDReadCustomChar(4);

 657:  

 658:             LCD_Move(2, *pxPos);

 659:             LCDWriteData(FULL_BLOCK_PATTERN);

 660:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 661:             LCDWriteData(FULL_BLOCK_PATTERN);

 662:  

 663:             LCD_Move(3, *pxPos);

 664:             LCDWriteData(FULL_BLOCK_PATTERN);

 665:             LCDWriteData(FULL_BLOCK_PATTERN);

 666:             LCDWriteData(FULL_BLOCK_PATTERN);

 667:  

 668:             LCD_Move(4, *pxPos);

 669:             LCDReadCustomChar(3);

 670:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 671:             LCDReadCustomChar(2);

 672:             

 673:             return;

 674:         }    

 675:         else if(*pStr == 'y' || *pStr == 'Y')

 676:         {

 677:             LCD_Move(1, *pxPos);

 678:             LCDReadCustomChar(4);

 679:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 680:             LCDReadCustomChar(4);

 681:  

 682:             LCD_Move(2, *pxPos);

 683:             LCDWriteData(FULL_BLOCK_PATTERN);

 684:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 685:             LCDWriteData(FULL_BLOCK_PATTERN);

 686:  

 687:             LCD_Move(3, *pxPos);

 688:             LCDWriteData(FULL_BLOCK_PATTERN);

 689:             LCDWriteData(FULL_BLOCK_PATTERN);

 690:             LCDWriteData(FULL_BLOCK_PATTERN);

 691:  

 692:             LCD_Move(4, *pxPos);

 693:             LCDReadCustomChar(3);

 694:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 695:             LCDReadCustomChar(2);

 696:             

 697:             return;

 698:         }    

 699:         else if(*pStr == 'z' || *pStr == 'Z')

 700:         {

 701:             LCD_Move(1, *pxPos);

 702:             LCDReadCustomChar(0);

 703:             LCDReadCustomChar(4);

 704:             LCDReadCustomChar(1);

 705:  

 706:             LCD_Move(2, *pxPos);

 707:             LCDWriteData(FULL_BLOCK_PATTERN);

 708:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 709:             LCDWriteData(FULL_BLOCK_PATTERN);

 710:  

 711:             LCD_Move(3, *pxPos);

 712:             LCDReadCustomChar(2);

 713:             LCDReadCustomChar(5);

 714:             LCDReadCustomChar(3);

 715:  

 716:             LCD_Move(4, *pxPos);

 717:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 718:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 719:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 720:             

 721:             return;

 722:         }

 723: }

 

Next, we are going to define the Interrupts routines:

   1: /***********************************************************************/

   2: /*                     PIC18 Interrupt Service Routines                */

   3: /***********************************************************************/

   4:     #pragma interruptlow LowISR

   5:     void LowISR(void)

   6:     {

   7:         if(INTCONbits.TMR0IF)                   // Check for Timer 0 interrupt

   8:         {

   9:             if (LEDTime)                        // If not already down to zero

  10:             {

  11:                 LEDTime--;                        // Countdown 1 tic

  12:             }

  13:     

  14:             INTCONbits.TMR0IF = 0;              // Reset interrupt flag

  15:             TMR0H = 0x00;                       // Reload Timer 0, upper bits, 1.67 secs

  16:             TMR0L = 0x00;                       // Reload Timer 0, lower bits

  17:         }

  18:     }

  19:     

  20:     #pragma interruptlow HighISR

  21:     void HighISR(void){}

  22:     #pragma code lowVector=0x18

  23:     void LowVector(void){_asm goto LowISR _endasm}

  24:     #pragma code highVector=0x8

  25:     void HighVector(void){_asm goto HighISR _endasm}

  26:     #pragma code // Return to default code section

 

Complete MAIN CODE:

   1: /***********************************************************************/

   2: /*                   LCD BIG LETTERS Test Program                         */

   3: /*                                                                     */

   4: /*  Created By: Hussein Nosair                                         */

   5: /*  Date      : 12/25/2009                                             */

   6: /*  Project   : LCDLOGO_18f4520_20091225                               */

   7: /*  Proj. Path: C:\                                                       */

   8: /*  File Name : test.c                                                 */

   9: /*                                                                     */

  10: /*    Description:                                                       */

  11: /*            This project will attempt to accomplish the following:       */

  12: /*            1. Utilize the LCD abilities of creating Custom Character  */

  13: /*                to build customized building blocks of the alphabets.  */

  14: /*            2. Utilize pre defined LCD characters.                       */

  15: /*            3. Define every alphabet letter pattern using the           */

  16: /*                customized building blocks.    Each letter will consist of*/

  17: /*                12 building blocks, 3 blocks per line/row.               */

  18: /*            4. At this time, we will display a pre-coded message       */

  19: /*                "HELLO" using 20x4 LCD. 20x4 LCD will only support 5   */

  20: /*                letters message at a time.                               */

  21: /*                                                                       */

  22: /*    Hardware:                                                           */

  23: /*            PIC18F4520                                                   */

  24: /*            External Clock (Oscillator) = 10MHz                           */

  25: /*            Internal Clock (Oscillator) = 40MHz                           */

  26: /*            LCD: 20x4 HDM20416L-1-YA0S                                   */

  27: /* Software:                                                           */

  28: /*            Editor:   MPLAB IDE v8.40                                   */

  29: /*            Compiler: MPLAB C18 v3.34                                   */

  30: /*            Internal clock is set to 4xPLL = 4x10MHz = 40MHz           */

  31: /*                                                                       */

  32: /*                                                                       */

  33: /* Author               Date      Comment                              */

  34: /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

  35: /* Hussein Nosair        12/25/09  test.c created                       */

  36: /***********************************************************************/

  37:  

  38:  

  39: /***********************************************************************/

  40: /*                      DEFINE THE MOTHER CODE                         */

  41: /***********************************************************************/

  42: //#define THIS_IS_STACK_APPLICATION               // Define this file to be the main Proj.'s File

  43:  

  44:  

  45: /***********************************************************************/

  46: /*                      DEFINE THE LIBRARIES                           */

  47: /***********************************************************************/

  48: #include "Compiler.h"                           // Compiler configuration library

  49:                                                 // define which compiler headers to use

  50: #include "HardwareProfile.h"                    // Hardware configuration library

  51:                                                 // define Configuration bits of PIC18F uC

  52: //#include "GenericTypeDefs.h"                  // Global definition library

  53:                                                 // contains user Type definitions

  54: //#include "Global_Variables.h"                 // Global variables library

  55:                                                 // contains user defined global variables

  56: #include "LCD.h"                                // LCD library

  57:                                                 // contains functions related to operation of LCD

  58: //#include "keys_scan.h"                        // Keypad keys library

  59: //#include "sound.h"                            // Sound library

  60: //#include "Tick.h"                             // Ethernet (Clock) ticker library

  61:  

  62:  

  63: /***********************************************************************/

  64: /*                     DEFINE STATIC VARIABLES                         */

  65: /***********************************************************************/

  66: #define TIMER1_LED_DELAY        2               // LED Timeout = 2*1.67sec

  67:  

  68: #define EMPTY_BLOCK_PATTERN        0xFE            // Pre-defined pattern by LCD

  69: #define FULL_BLOCK_PATTERN        0xFF            // Pre-defined pattern by LCD

  70:  

  71:  

  72: /***********************************************************************/

  73: /*                     DEFINE GLOBAL VARIABLES                         */

  74: /***********************************************************************/

  75: unsigned char LEDTime;                          // Define LED timout

  76: //unsigned char dwInternalTicks;                // Define Ethernet tick counter

  77:  

  78: // Define customized building blocks of alphabets letters.

  79: //---------------------------------------------------------

  80: const unsigned char aShapes[8][8] = { {0 , 0 , 0 , 1 , 3 , 7 , 15 , 31},        // Patter 1 saved to LCD RAM @ 0

  81:                                          {0 , 0 , 0 , 16 , 24 , 28 , 30 , 31},        // Patter 2 saved to LCD RAM @ 1

  82:                                          {31 , 15 , 7 , 3 , 1 , 0 , 0 , 0},        // Patter 3 saved to LCD RAM @ 2

  83:                                          {31 , 30 , 28 , 24 , 16 , 0 , 0 , 0},        // Patter 4 saved to LCD RAM @ 3

  84:                                          {0 , 0 , 0 , 31 , 31 , 31 , 31 , 31},        // Patter 5 saved to LCD RAM @ 4

  85:                                          {31 , 31 , 31 , 31 , 31 , 0 , 0 , 0},        // Patter 6 saved to LCD RAM @ 5

  86:                                          {31 , 31 , 31 , 30 , 28 , 24 , 16 , 0},    // Patter 7 saved to LCD RAM @ 6

  87:                                          {0 , 16 , 24 , 28 , 30 , 31 , 31 , 31}    // Patter 8 saved to LCD RAM @ 7

  88:                                     };

  89:  

  90: // Define message of 5 letters to be displayed on the LCD

  91: //---------------------------------------------------------                                

  92: unsigned char aText[6] = "HELLO";

  93:  

  94: unsigned char *paText;                            // Define the letter to be displayed

  95: unsigned char xPos;                                // Define the LCD cursor location

  96:  

  97:  

  98: /***********************************************************************/

  99: /*                     DEFINE PRIVATE SUBROUTINES                      */

 100: /***********************************************************************/

 101: // Define Board's hardware initialization subroutine

 102: //----------------------------------------------------

 103: void InitializeBoard(void);                     

 104:  

 105: // Define letters of alphabets patters

 106: //----------------------------------------------------

 107: void DrawCharacter(unsigned char *pStr, unsigned char *pxPos);

 108:  

 109:  

 110: /***********************************************************************/

 111: /*                     PIC18 Interrupt Service Routines                */

 112: /***********************************************************************/

 113:     #pragma interruptlow LowISR

 114:     void LowISR(void)

 115:     {

 116:         if(INTCONbits.TMR0IF)                   // Check for Timer 0 interrupt

 117:         {

 118:             if (LEDTime)                        // If not already down to zero

 119:             {

 120:                 LEDTime--;                        // Countdown 1 tic

 121:             }

 122:     

 123:             INTCONbits.TMR0IF = 0;              // Reset interrupt flag

 124:             TMR0H = 0x00;                       // Reload Timer 0, upper bits, 1.67 secs

 125:             TMR0L = 0x00;                       // Reload Timer 0, lower bits

 126:         }

 127:     }

 128:     

 129:     #pragma interruptlow HighISR

 130:     void HighISR(void){}

 131:     #pragma code lowVector=0x18

 132:     void LowVector(void){_asm goto LowISR _endasm}

 133:     #pragma code highVector=0x8

 134:     void HighVector(void){_asm goto HighISR _endasm}

 135:     #pragma code // Return to default code section

 136:  

 137:  

 138: /********************************************************************/

 139: /*                     MAIN PROGRAM ROUTINE                         */

 140: /********************************************************************/

 141: void main(void)

 142: { 

 143:     unsigned char i;

 144:           

 145:     /************** INITIALIZE THE BOARD ************/

 146:     InitializeBoard();                  // Initialize board and PIC hardware

 147:  

 148:     /************** PREPARE THE LCD ****************/

 149:     LCDErase();                         // Clear the LCD

 150:     LCDHome();

 151:  

 152:     // Load Custom Characters into LCD RAM

 153:     //---------------------------------------

 154:     for(i=0;i<8;i++)

 155:     {

 156:         LCDCustomChar(i, aShapes[i]);

 157:         LCD_PAUSE();

 158:     }

 159:     

 160:     // Init. Text array pointer

 161:     //---------------------------

 162:     paText = &aText[0];

 163:     xPos = 0;

 164:         

 165:     

 166:     /********************** MAIN PROGRAM INFINITE LOOP *******************/

 167:     while(1)                                    // Loop infinitly

 168:     {

 169:         if (!LEDTime)                            // Check LED time out.

 170:         {

 171:             // Toggle LED

 172:             //-----------------------------

 173:             LED_IO ^= 1;                         // Turn of LED after some delay indicating no using keypad

 174:  

 175:             // Display Text array message

 176:             //----------------------------

 177:             paText = &aText[0];

 178:             xPos = 0;

 179:             for(i=0; i<5; i++)

 180:             {

 181:                 DrawCharacter(paText, &xPos);

 182:                 *paText++;

 183:                 xPos += 4;

 184:             }

 185:             LEDTime = 1;

 186:             while(LEDTime);

 187:             LCDErase();

 188:             

 189:             LEDTime = TIMER1_LED_DELAY;            // Restart counter.

 190:         }

 191:  

 192:  

 193:         ClrWdt();                               // Clear Watchdog timer

 194:  

 195:     }       

 196: }

 197:  

 198: /********************************************************************

 199: *       Function Name:  InitializeBoard                             *

 200: *       Return Value:   None                                        *

 201: *       Parameters:     void                                        *

 202: *       Description:    This routine initialize the on board's      *

 203: *                       modules and microprocessor.                 *

 204: ********************************************************************/

 205: void InitializeBoard(void)

 206: {

 207:     RCON    = 0x80;

 208:     INTCON  = 0xE0;

 209:     INTCON2 = 0x84;

 210:     INTCON3 = 0x00;

 211:     

 212:     #if defined(__18F97J60)

 213:         PIR1 = 0x00;

 214:         PIR2 = 0x00;

 215:         PIR3 = 0x00;

 216:         PIE1 = 0x00;

 217:         PIE2 = 0x00;

 218:         PIE3 = 0x00;

 219:         LATA = 0xC0;

 220:     #endif

 221:     

 222:     // Initiailize Digital Pins

 223:     //----------------------------

 224:     ADCON1 = 0x0F;              // Analog pins to digital

 225:     CMCON = 0x00; //0xCF;

 226:     CVRCON = 0x00;

 227:     

 228:     #if defined(__18F97J60)

 229:         PORTAbits.RJPU = 0;

 230:     #endif

 231:  

 232:     // Enable internal PORTB pull-ups

 233:     //----------------------------

 234:     INTCON2bits.RBPU = 1;

 235:     

 236:     // Enable Interrupts

 237:     //----------------------------

 238:     RCONbits.IPEN = 1;            // Enable interrupt priorities

 239:     INTCONbits.GIEH = 1;

 240:     INTCONbits.GIEL = 1;

 241:  

 242:     // Set Internal Oscillator/Clock

 243:     //----------------------------

 244:     OSCTUNE = 0x00;             //<-----------

 245:     

 246:     // Initialize LEDs

 247:     //--------------------------

 248:     LED_TRIS = 0;

 249:     LED_IO = 0;

 250:  

 251:     // Initialize LCD

 252:     //--------------------------

 253:     LCD_DATA_TRIS = 0x0F;   // Set Data Bus Direction to output

 254:     LCD_RD_WR_TRIS  = 0;    // Set R/W pin direction to output

 255:     LCD_RS_TRIS     = 0;    // Set Reset pin direction to output

 256:     LCD_E_TRIS      = 0;    // Set Enable pin direction to output

 257:     DelayMs(50);            // wait for 15ms to allow the voltage to  rise to moe than 4.5V

 258:     LCDInit();

 259:     

 260:     // Initialize KEYs

 261: //    Keys_init();

 262:     

 263:     // Initialize Speaker

 264: //    BUZZER_TRIS = 0;

 265: //    BUZZER = 0;

 266:  

 267:     // Initialize Timer 0

 268:     //--------------------------

 269:     // Use Timer0 for 8 bit processors

 270:     // Initialize the time

 271:     TMR0H = 0;

 272:     TMR0L = 0;

 273:  

 274:     // Set up the timer interrupt

 275:     INTCON2bits.TMR0IP = 0;        // Low priority

 276:     INTCONbits.TMR0IF = 0;

 277:     INTCONbits.TMR0IE = 1;        // Enable interrupt

 278:  

 279:     // Timer0 on, 16-bit, internal timer, 1:256 prescalar

 280:     T0CON = 0x87;

 281:  

 282:  

 283:     // Start Clock

 284: //    TickInit();    

 285: }

 286:  

 287: /********************************************************************

 288: *       Function Name:  DrawCharacter                                *

 289: *       Return Value:   None                                        *

 290: *       Parameters:     letter pointer, cursor location pointer     *

 291: *       Description:    This routine will display the capital       *

 292: *                       letter of characters defined in the message *

 293: ********************************************************************/

 294: void DrawCharacter(unsigned char *pStr, unsigned char *pxPos)

 295: {

 296:         if(*pStr == 'a' || *pStr == 'A')

 297:         {

 298:             LCD_Move(1, *pxPos);

 299:             LCDReadCustomChar(0);

 300:             LCDReadCustomChar(4);

 301:             LCDReadCustomChar(1);

 302:  

 303:             LCD_Move(2, *pxPos);

 304:             LCDWriteData(FULL_BLOCK_PATTERN);

 305:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 306:             LCDWriteData(FULL_BLOCK_PATTERN);

 307:  

 308:             LCD_Move(3, *pxPos);

 309:             LCDWriteData(FULL_BLOCK_PATTERN);

 310:             LCDReadCustomChar(5);

 311:             LCDWriteData(FULL_BLOCK_PATTERN);

 312:  

 313:             LCD_Move(4, *pxPos);

 314:             LCDReadCustomChar(5);

 315:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 316:             LCDReadCustomChar(5);

 317:             

 318:             return;

 319:         }    

 320:         else if(*pStr == 'b' || *pStr == 'B')

 321:         {

 322:             LCD_Move(1, *pxPos);

 323:             LCDReadCustomChar(4);

 324:             LCDReadCustomChar(4);

 325:             LCDReadCustomChar(1);

 326:  

 327:             LCD_Move(2, *pxPos);

 328:             LCDWriteData(FULL_BLOCK_PATTERN);

 329:             LCDReadCustomChar(0);

 330:             LCDReadCustomChar(6);

 331:  

 332:             LCD_Move(3, *pxPos);

 333:             LCDWriteData(FULL_BLOCK_PATTERN);

 334:             LCDReadCustomChar(2);

 335:             LCDReadCustomChar(7);

 336:  

 337:             LCD_Move(4, *pxPos);

 338:             LCDReadCustomChar(5);

 339:             LCDReadCustomChar(5);

 340:             LCDReadCustomChar(3);

 341:             

 342:             return;

 343:         }    

 344:         else if(*pStr == 'c' || *pStr == 'C')

 345:         {

 346:             LCD_Move(1, *pxPos);

 347:             LCDReadCustomChar(0);

 348:             LCDReadCustomChar(4);

 349:             LCDReadCustomChar(1);

 350:  

 351:             LCD_Move(2, *pxPos);

 352:             LCDWriteData(FULL_BLOCK_PATTERN);

 353:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 354:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 355:  

 356:             LCD_Move(3, *pxPos);

 357:             LCDWriteData(FULL_BLOCK_PATTERN);

 358:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 359:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 360:  

 361:             LCD_Move(4, *pxPos);

 362:             LCDReadCustomChar(2);

 363:             LCDReadCustomChar(5);

 364:             LCDReadCustomChar(3);

 365:             

 366:             return;

 367:         }    

 368:         else if(*pStr == 'd' || *pStr == 'D')

 369:         {

 370:             LCD_Move(1, *pxPos);

 371:             LCDReadCustomChar(4);

 372:             LCDReadCustomChar(4);

 373:             LCDReadCustomChar(1);

 374:  

 375:             LCD_Move(2, *pxPos);

 376:             LCDWriteData(FULL_BLOCK_PATTERN);

 377:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 378:             LCDWriteData(FULL_BLOCK_PATTERN);

 379:  

 380:             LCD_Move(3, *pxPos);

 381:             LCDWriteData(FULL_BLOCK_PATTERN);

 382:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 383:             LCDWriteData(FULL_BLOCK_PATTERN);

 384:  

 385:             LCD_Move(4, *pxPos);

 386:             LCDReadCustomChar(5);

 387:             LCDReadCustomChar(5);

 388:             LCDReadCustomChar(3);

 389:             

 390:             return;

 391:         }    

 392:         else if(*pStr == 'e' || *pStr == 'E')

 393:         {

 394:             LCD_Move(1, *pxPos);

 395:             LCDReadCustomChar(4);

 396:             LCDReadCustomChar(4);

 397:             LCDReadCustomChar(4);

 398:  

 399:             LCD_Move(2, *pxPos);

 400:             LCDWriteData(FULL_BLOCK_PATTERN);

 401:             LCDReadCustomChar(4);

 402:             LCDReadCustomChar(4);

 403:  

 404:             LCD_Move(3, *pxPos);

 405:             LCDWriteData(FULL_BLOCK_PATTERN);

 406:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 407:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 408:  

 409:             LCD_Move(4, *pxPos);

 410:             LCDReadCustomChar(5);

 411:             LCDReadCustomChar(5);

 412:             LCDReadCustomChar(5);

 413:             

 414:             return;

 415:         }    

 416:         else if(*pStr == 'f' || *pStr == 'F')

 417:         {

 418:             LCD_Move(1, *pxPos);

 419:             LCDReadCustomChar(4);

 420:             LCDReadCustomChar(4);

 421:             LCDReadCustomChar(4);

 422:  

 423:             LCD_Move(2, *pxPos);

 424:             LCDWriteData(FULL_BLOCK_PATTERN);

 425:             LCDReadCustomChar(4);

 426:             LCDReadCustomChar(4);

 427:  

 428:             LCD_Move(3, *pxPos);

 429:             LCDWriteData(FULL_BLOCK_PATTERN);

 430:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 431:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 432:  

 433:             LCD_Move(4, *pxPos);

 434:             LCDReadCustomChar(5);

 435:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 436:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 437:             

 438:             return;

 439:         }    

 440:         else if(*pStr == 'g' || *pStr == 'G')

 441:         {

 442:             LCD_Move(1, *pxPos);

 443:             LCDReadCustomChar(0);

 444:             LCDReadCustomChar(4);

 445:             LCDReadCustomChar(1);

 446:  

 447:             LCD_Move(2, *pxPos);

 448:             LCDWriteData(FULL_BLOCK_PATTERN);

 449:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 450:             LCDReadCustomChar(5);

 451:  

 452:             LCD_Move(3, *pxPos);

 453:             LCDWriteData(FULL_BLOCK_PATTERN);

 454:             LCDReadCustomChar(5);

 455:             LCDWriteData(FULL_BLOCK_PATTERN);

 456:  

 457:             LCD_Move(4, *pxPos);

 458:             LCDReadCustomChar(2);

 459:             LCDReadCustomChar(5);

 460:             LCDReadCustomChar(3);

 461:             

 462:             return;

 463:         }    

 464:         else if(*pStr == 'h' || *pStr == 'H')

 465:         {

 466:             LCD_Move(1, *pxPos);

 467:             LCDReadCustomChar(4);

 468:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 469:             LCDReadCustomChar(4);

 470:  

 471:             LCD_Move(2, *pxPos);

 472:             LCDWriteData(FULL_BLOCK_PATTERN);

 473:             LCDReadCustomChar(4);

 474:             LCDWriteData(FULL_BLOCK_PATTERN);

 475:  

 476:             LCD_Move(3, *pxPos);

 477:             LCDWriteData(FULL_BLOCK_PATTERN);

 478:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 479:             LCDWriteData(FULL_BLOCK_PATTERN);

 480:  

 481:             LCD_Move(4, *pxPos);

 482:             LCDReadCustomChar(5);

 483:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 484:             LCDReadCustomChar(5);

 485:             

 486:             return;

 487:         }    

 488:         else if(*pStr == 'i' || *pStr == 'I')

 489:         {

 490:             LCD_Move(1, *pxPos);

 491:             LCDReadCustomChar(4);

 492:             LCDReadCustomChar(4);

 493:             LCDReadCustomChar(4);

 494:  

 495:             LCD_Move(2, *pxPos);

 496:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 497:             LCDWriteData(FULL_BLOCK_PATTERN);

 498:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 499:  

 500:             LCD_Move(3, *pxPos);

 501:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 502:             LCDWriteData(FULL_BLOCK_PATTERN);

 503:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 504:  

 505:             LCD_Move(4, *pxPos);

 506:             LCDReadCustomChar(5);

 507:             LCDReadCustomChar(5);

 508:             LCDReadCustomChar(5);

 509:             

 510:             return;

 511:         }    

 512:         else if(*pStr == 'j' || *pStr == 'J')

 513:         {

 514:             LCD_Move(1, *pxPos);

 515:             LCDReadCustomChar(4);

 516:             LCDReadCustomChar(4);

 517:             LCDReadCustomChar(4);

 518:  

 519:             LCD_Move(2, *pxPos);

 520:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 521:             LCDWriteData(FULL_BLOCK_PATTERN);

 522:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 523:  

 524:             LCD_Move(3, *pxPos);

 525:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 526:             LCDWriteData(FULL_BLOCK_PATTERN);

 527:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 528:  

 529:             LCD_Move(4, *pxPos);

 530:             LCDReadCustomChar(5);

 531:             LCDReadCustomChar(3);

 532:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 533:             

 534:             return;

 535:         }    

 536:         else if(*pStr == 'k' || *pStr == 'K')

 537:         {

 538:             LCD_Move(1, *pxPos);

 539:             LCDReadCustomChar(4);

 540:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 541:             LCDReadCustomChar(4);

 542:  

 543:             LCD_Move(2, *pxPos);

 544:             LCDWriteData(FULL_BLOCK_PATTERN);

 545:             LCDReadCustomChar(0);

 546:             LCDReadCustomChar(6);

 547:  

 548:             LCD_Move(3, *pxPos);

 549:             LCDWriteData(FULL_BLOCK_PATTERN);

 550:             LCDReadCustomChar(2);

 551:             LCDReadCustomChar(7);

 552:  

 553:             LCD_Move(4, *pxPos);

 554:             LCDReadCustomChar(5);

 555:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 556:             LCDReadCustomChar(5);

 557:             

 558:             return;

 559:         }    

 560:         else if(*pStr == 'l' || *pStr == 'L')

 561:         {

 562:             LCD_Move(1, *pxPos);

 563:             LCDReadCustomChar(4);

 564:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 565:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 566:  

 567:             LCD_Move(2, *pxPos);

 568:             LCDWriteData(FULL_BLOCK_PATTERN);

 569:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 570:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 571:  

 572:             LCD_Move(3, *pxPos);

 573:             LCDWriteData(FULL_BLOCK_PATTERN);

 574:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 575:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 576:  

 577:             LCD_Move(4, *pxPos);

 578:             LCDReadCustomChar(5);

 579:             LCDReadCustomChar(5);

 580:             LCDReadCustomChar(5);

 581:             

 582:             return;

 583:         }    

 584:         else if(*pStr == 'm' || *pStr == 'M')

 585:         {

 586:             LCD_Move(1, *pxPos);

 587:             LCDReadCustomChar(1);

 588:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 589:             LCDReadCustomChar(0);

 590:  

 591:             LCD_Move(2, *pxPos);

 592:             LCDWriteData(FULL_BLOCK_PATTERN);

 593:             LCDWriteData(FULL_BLOCK_PATTERN);

 594:             LCDWriteData(FULL_BLOCK_PATTERN);

 595:  

 596:             LCD_Move(3, *pxPos);

 597:             LCDWriteData(FULL_BLOCK_PATTERN);

 598:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 599:             LCDWriteData(FULL_BLOCK_PATTERN);

 600:  

 601:             LCD_Move(4, *pxPos);

 602:             LCDReadCustomChar(5);

 603:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 604:             LCDReadCustomChar(5);

 605:             

 606:             return;

 607:         }    

 608:         else if(*pStr == 'n' || *pStr == 'N')

 609:         {

 610:             LCD_Move(1, *pxPos);

 611:             LCDReadCustomChar(4);

 612:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 613:             LCDReadCustomChar(4);

 614:  

 615:             LCD_Move(2, *pxPos);

 616:             LCDWriteData(FULL_BLOCK_PATTERN);

 617:             LCDReadCustomChar(7);

 618:             LCDWriteData(FULL_BLOCK_PATTERN);

 619:  

 620:             LCD_Move(3, *pxPos);

 621:             LCDWriteData(FULL_BLOCK_PATTERN);

 622:             LCDReadCustomChar(2);

 623:             LCDWriteData(FULL_BLOCK_PATTERN);

 624:  

 625:             LCD_Move(4, *pxPos);

 626:             LCDReadCustomChar(5);

 627:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 628:             LCDReadCustomChar(5);

 629:             

 630:             return;

 631:         }    

 632:         else if(*pStr == 'o' || *pStr == 'O')

 633:         {

 634:             LCD_Move(1, *pxPos);

 635:             LCDReadCustomChar(0);

 636:             LCDReadCustomChar(4);

 637:             LCDReadCustomChar(1);

 638:  

 639:             LCD_Move(2, *pxPos);

 640:             LCDWriteData(FULL_BLOCK_PATTERN);

 641:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 642:             LCDWriteData(FULL_BLOCK_PATTERN);

 643:  

 644:             LCD_Move(3, *pxPos);

 645:             LCDWriteData(FULL_BLOCK_PATTERN);

 646:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 647:             LCDWriteData(FULL_BLOCK_PATTERN);

 648:  

 649:             LCD_Move(4, *pxPos);

 650:             LCDReadCustomChar(2);

 651:             LCDReadCustomChar(5);

 652:             LCDReadCustomChar(3);

 653:             

 654:             return;

 655:         }    

 656:         else if(*pStr == 'p' || *pStr == 'P')

 657:         {

 658:             LCD_Move(1, *pxPos);

 659:             LCDReadCustomChar(4);

 660:             LCDReadCustomChar(4);

 661:             LCDReadCustomChar(1);

 662:  

 663:             LCD_Move(2, *pxPos);

 664:             LCDWriteData(FULL_BLOCK_PATTERN);

 665:             LCDReadCustomChar(4);

 666:             LCDReadCustomChar(6);

 667:  

 668:             LCD_Move(3, *pxPos);

 669:             LCDWriteData(FULL_BLOCK_PATTERN);

 670:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 671:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 672:  

 673:             LCD_Move(4, *pxPos);

 674:             LCDReadCustomChar(5);

 675:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 676:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 677:             

 678:             return;

 679:         }    

 680:         else if(*pStr == 'q' || *pStr == 'Q')

 681:         {

 682:             LCD_Move(1, *pxPos);

 683:             LCDReadCustomChar(0);

 684:             LCDReadCustomChar(4);

 685:             LCDReadCustomChar(1);

 686:  

 687:             LCD_Move(2, *pxPos);

 688:             LCDWriteData(FULL_BLOCK_PATTERN);

 689:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 690:             LCDWriteData(FULL_BLOCK_PATTERN);

 691:  

 692:             LCD_Move(3, *pxPos);

 693:             LCDWriteData(FULL_BLOCK_PATTERN);

 694:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 695:             LCDWriteData(FULL_BLOCK_PATTERN);

 696:  

 697:             LCD_Move(4, *pxPos);

 698:             LCDReadCustomChar(2);

 699:             LCDReadCustomChar(5);

 700:             LCDWriteData(FULL_BLOCK_PATTERN);

 701:             

 702:             return;

 703:         }    

 704:         else if(*pStr == 'r' || *pStr == 'R')

 705:         {

 706:             LCD_Move(1, *pxPos);

 707:             LCDReadCustomChar(4);

 708:             LCDReadCustomChar(4);

 709:             LCDReadCustomChar(1);

 710:  

 711:             LCD_Move(2, *pxPos);

 712:             LCDWriteData(FULL_BLOCK_PATTERN);

 713:             LCDReadCustomChar(0);

 714:             LCDReadCustomChar(6);

 715:  

 716:             LCD_Move(3, *pxPos);

 717:             LCDWriteData(FULL_BLOCK_PATTERN);

 718:             LCDReadCustomChar(2);

 719:             LCDReadCustomChar(7);

 720:  

 721:             LCD_Move(4, *pxPos);

 722:             LCDReadCustomChar(5);

 723:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 724:             LCDReadCustomChar(5);

 725:             

 726:             return;

 727:         }    

 728:         else if(*pStr == 's' || *pStr == 'S')

 729:         {

 730:             LCD_Move(1, *pxPos);

 731:             LCDReadCustomChar(0);

 732:             LCDReadCustomChar(4);

 733:             LCDReadCustomChar(1);

 734:  

 735:             LCD_Move(2, *pxPos);

 736:             LCDWriteData(FULL_BLOCK_PATTERN);

 737:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 738:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 739:  

 740:             LCD_Move(3, *pxPos);

 741:             LCDReadCustomChar(2);

 742:             LCDReadCustomChar(5);

 743:             LCDReadCustomChar(7);

 744:  

 745:             LCD_Move(4, *pxPos);

 746:             LCDReadCustomChar(2);

 747:             LCDReadCustomChar(5);

 748:             LCDReadCustomChar(3);

 749:             

 750:             return;

 751:         }    

 752:         else if(*pStr == 't' || *pStr == 'T')

 753:         {

 754:             LCD_Move(1, *pxPos);

 755:             LCDReadCustomChar(4);

 756:             LCDReadCustomChar(4);

 757:             LCDReadCustomChar(4);

 758:  

 759:             LCD_Move(2, *pxPos);

 760:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 761:             LCDWriteData(FULL_BLOCK_PATTERN);

 762:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 763:  

 764:             LCD_Move(3, *pxPos);

 765:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 766:             LCDWriteData(FULL_BLOCK_PATTERN);

 767:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 768:  

 769:             LCD_Move(4, *pxPos);

 770:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 771:             LCDReadCustomChar(5);

 772:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 773:             

 774:             return;

 775:         }    

 776:         else if(*pStr == 'u' || *pStr == 'U')

 777:         {

 778:             LCD_Move(1, *pxPos);

 779:             LCDReadCustomChar(4);

 780:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 781:             LCDReadCustomChar(4);

 782:  

 783:             LCD_Move(2, *pxPos);

 784:             LCDWriteData(FULL_BLOCK_PATTERN);

 785:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 786:             LCDWriteData(FULL_BLOCK_PATTERN);

 787:  

 788:             LCD_Move(3, *pxPos);

 789:             LCDWriteData(FULL_BLOCK_PATTERN);

 790:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 791:             LCDWriteData(FULL_BLOCK_PATTERN);

 792:  

 793:             LCD_Move(4, *pxPos);

 794:             LCDReadCustomChar(2);

 795:             LCDReadCustomChar(5);

 796:             LCDReadCustomChar(3);

 797:             

 798:             return;

 799:         }    

 800:         else if(*pStr == 'v' || *pStr == 'V')

 801:         {

 802:             LCD_Move(1, *pxPos);

 803:             LCDReadCustomChar(4);

 804:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 805:             LCDReadCustomChar(4);

 806:  

 807:             LCD_Move(2, *pxPos);

 808:             LCDWriteData(FULL_BLOCK_PATTERN);

 809:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 810:             LCDWriteData(FULL_BLOCK_PATTERN);

 811:  

 812:             LCD_Move(3, *pxPos);

 813:             LCDWriteData(FULL_BLOCK_PATTERN);

 814:             LCDReadCustomChar(0);

 815:             LCDReadCustomChar(6);

 816:  

 817:             LCD_Move(4, *pxPos);

 818:             LCDReadCustomChar(2);

 819:             LCDReadCustomChar(3);

 820:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 821:             

 822:             return;

 823:         }    

 824:         else if(*pStr == 'w' || *pStr == 'W')

 825:         {

 826:             LCD_Move(1, *pxPos);

 827:             LCDReadCustomChar(4);

 828:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 829:             LCDReadCustomChar(4);

 830:  

 831:             LCD_Move(2, *pxPos);

 832:             LCDWriteData(FULL_BLOCK_PATTERN);

 833:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 834:             LCDWriteData(FULL_BLOCK_PATTERN);

 835:  

 836:             LCD_Move(3, *pxPos);

 837:             LCDWriteData(FULL_BLOCK_PATTERN);

 838:             LCDWriteData(FULL_BLOCK_PATTERN);

 839:             LCDWriteData(FULL_BLOCK_PATTERN);

 840:  

 841:             LCD_Move(4, *pxPos);

 842:             LCDReadCustomChar(3);

 843:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 844:             LCDReadCustomChar(2);

 845:             

 846:             return;

 847:         }    

 848:         else if(*pStr == 'x' || *pStr == 'X')

 849:         {

 850:             LCD_Move(1, *pxPos);

 851:             LCDReadCustomChar(4);

 852:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 853:             LCDReadCustomChar(4);

 854:  

 855:             LCD_Move(2, *pxPos);

 856:             LCDWriteData(FULL_BLOCK_PATTERN);

 857:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 858:             LCDWriteData(FULL_BLOCK_PATTERN);

 859:  

 860:             LCD_Move(3, *pxPos);

 861:             LCDWriteData(FULL_BLOCK_PATTERN);

 862:             LCDWriteData(FULL_BLOCK_PATTERN);

 863:             LCDWriteData(FULL_BLOCK_PATTERN);

 864:  

 865:             LCD_Move(4, *pxPos);

 866:             LCDReadCustomChar(3);

 867:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 868:             LCDReadCustomChar(2);

 869:             

 870:             return;

 871:         }    

 872:         else if(*pStr == 'y' || *pStr == 'Y')

 873:         {

 874:             LCD_Move(1, *pxPos);

 875:             LCDReadCustomChar(4);

 876:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 877:             LCDReadCustomChar(4);

 878:  

 879:             LCD_Move(2, *pxPos);

 880:             LCDWriteData(FULL_BLOCK_PATTERN);

 881:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 882:             LCDWriteData(FULL_BLOCK_PATTERN);

 883:  

 884:             LCD_Move(3, *pxPos);

 885:             LCDWriteData(FULL_BLOCK_PATTERN);

 886:             LCDWriteData(FULL_BLOCK_PATTERN);

 887:             LCDWriteData(FULL_BLOCK_PATTERN);

 888:  

 889:             LCD_Move(4, *pxPos);

 890:             LCDReadCustomChar(3);

 891:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 892:             LCDReadCustomChar(2);

 893:             

 894:             return;

 895:         }    

 896:         else if(*pStr == 'z' || *pStr == 'Z')

 897:         {

 898:             LCD_Move(1, *pxPos);

 899:             LCDReadCustomChar(0);

 900:             LCDReadCustomChar(4);

 901:             LCDReadCustomChar(1);

 902:  

 903:             LCD_Move(2, *pxPos);

 904:             LCDWriteData(FULL_BLOCK_PATTERN);

 905:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 906:             LCDWriteData(FULL_BLOCK_PATTERN);

 907:  

 908:             LCD_Move(3, *pxPos);

 909:             LCDReadCustomChar(2);

 910:             LCDReadCustomChar(5);

 911:             LCDReadCustomChar(3);

 912:  

 913:             LCD_Move(4, *pxPos);

 914:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 915:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 916:             LCDWriteData(EMPTY_BLOCK_PATTERN);

 917:             

 918:             return;

 919:         }

 920: }

 

Pictures:

One Response to “20×4 LCD :: Display Big Letters”

  1. […] 20×4 LCD :: Display Big Letters […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: