Microprocessor Engineering by FKij3B

VIEWS: 8 PAGES: 20

									LCD's




        1
LCD Types
               Many types available. Most
                common are:
                 Character
                      Pre-programmed with a set of
                       alphanumeric characters & symbols
                      Size range from 8×1 to 40×4 (characters)
                 Graphic
                      Either graphic only (set each pixel
                       individually ), or both graphic & character
                       modes
                      Common sizes (pixels) 128×64, 240×128,
                       320×240 (QVGA) etc..


                                                              4-2
LCD backlights & Display properties
   Backlights
        CCFL (needs converter), LED & OLED (no backlight required)
   Display properties
        Reflective,Transmissive, Transflective (better in sunlight)




                                                                       4-3
LCD polarizer
                Reflective displays have an opaque rear polarizer that includes a diffuse reflector, such
                as brushed aluminum. This layer reflects polarized ambient light that has entered the front
                of the display back trough the LCD cell. Reflective displays require ambient light to be
                seen. They exhibit high brightness, excellent contrast, and wide viewing angles. They are
                particularly suitable for use in battery operated equipment where an adequate level of light
                is always available. Reflective LCD's cannot be backlit, however they can be front lighted
                in some applications.

               Transmissive displays have a clear polarizer on the front and the back. The display
               therefore depends on light coming through from the back of the display toward the
               observer in order to be seen. Most, but not all transmissive displays are negative image,
               and we sometimes add colored filters to different areas of the display to highlight
               different annunciators. Another example of a transmissive polarizer display would be a
               transparent window where you could see the segments superimposed over your line of
               vision through the display window (this assumes a sufficient ambient light source exists
               on either side of the window).

                Transflective displays have a rear polarizer which includes a translucent material
                which reflects part of the ambient light, and also transmits backlighting. As the name
                implies, it is a compromise between the transmissive and reflective viewing mode.
                Used in reflection, it is not as bright and has lower contrast than the reflective type
                LCD, but it can be backlit for use in low light conditions. This polarizer is the best
                selection for a display that can be used in all lighting conditions with a backlight.

    Source - http://www.pacificdisplay.com/lcd_polarizers.htm                                      4-4
LCD Pin assignments
   Pin
        Symbol    Level     I/O           Function
 number
    1     Vss       -        -       Power supply (GND)
    2     Vcc       -        -        Power supply (+5V)
    3     Vee       -        -           Contrast adjust
                                      0 = Instruction input
   4      RS       0/1       I
                                         1 = Data input
                                   0 = Write to LCD module
   5     R/W       0/1       I
                                  1 = Read from LCD module
    6     E      1, 1-->0     I          Enable signal
    7    DB0        0/1     I/O      Data bus line 0 (LSB)
    8    DB1        0/1     I/O          Data bus line 1
    9    DB2        0/1     I/O          Data bus line 2
   10    DB3        0/1     I/O          Data bus line 3
   11    DB4        0/1     I/O          Data bus line 4
   12    DB5        0/1     I/O          Data bus line 5
   13    DB6        0/1     I/O          Data bus line 6
   14    DB7        0/1     I/O      Data bus line 7 (MSB)

                                                              4-5
LCD Driver Block Diagram




                           4-6
LCD on the MCB23XX Boards
   Keil MCB23xx uses 4 bit mode!
LCD Pins LPC23XX pins
 - DB4 = P1.24
 - DB5 = P1.25
 - DB6 = P1.26
 - DB7 = P1.27
 -E     = P1.31 (for V1 P1.30)
 - RW = P1.29
 - RS = P1.28




                                    4-7
Commands for character modules

                              RS   R/W DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
                   Function
                   set         0 0      0 0     1 DL    N   F   *     #




                                                                4-8
4 Bit initialization


                       LCD_RS(0)                   /* Instruction input*/
                        lcd_write_4bit (0x3);      /* Set LCD in known state */
                        delay (4100);              /* Write 0x3 × 3          */
                        lcd_write_4bit (0x3);
                        delay (100);
                        lcd_write_4bit (0x3);
                        lcd_write_4bit (0x2);   /* Select 4-bit interface */
                        lcd_write_cmd (0x28);   /* 2 lines, 5x8 character matrix*/
                        lcd_write_cmd (0x0C);   // Dsplayn cntrl:Disp=ON,Curs/Blk=OFF
                        lcd_write_cmd (0x06);   /* Entry mode: Move right, no shift */




                                                                              4-9
DISPLAY CHARACTER POSITION AND
CHARACTER ADDRESS




                             4-10
LCD Functions
    User functions - call these from your program (function prototypes are in
     the lcd header file!)
         void   lcd_init      (void);
         void   lcd_clear     (void);
         void   lcd_putchar   (char c);
         void   set_cursor    (unsigned char column, unsigned char line);
         void   lcd_print     (unsigned char const *string);

   Extract from sample program
          lcd_init();
          lcd_clear();
          lcd_print (" Embedded Systems");
          set_cursor (0, 1);
          lcd_print ("     Alan     ");



                                                                                 4-11
Low level non user LCD functions
    Also a number of low level functions that are called from the
     user functions see the lcd.c file.
         void lcd_write_cmd (unsigned char c)
         void lcd_write_4bit (unsigned char c)
         static unsigned char wait_while_busy (void)
         static unsigned char lcd_read_status (void)

void lcd_write_cmd (unsigned char c)
{
  wait_while_busy();

    LCD_RS(0)
    lcd_write_4bit (c>>4);
    lcd_write_4bit (c);
}
                                                                 4-12
Printing variables to the LCD
   To print variables to the LCD it is necessary to convert the variable to its
    ASCII character representation using the sprintf() function and then
    printing out the characters using the lcd_print() function.
      Example
        sprintf(lcd_buf, "%d", x); //convert x to ASCII
        lcd_print(lcd_buf); // print to LCD

   where the variable x is an integer to be printed in decimal (hence the %d
    in the sprintf format string) and lcd_buf is an array of char declared big
    enough to hold the characters of the number + 1 extra character (for the
    end of string NULL character).
   E.g. char lcd_buf[17]; // LCD buffer big enough for one line of characters
    on the LCD


                                                                               4-13
LCD Character generation
   User defines characters can be stored in the LCD CGRAM memory
   Up to 8 characters can be stored


                     Column                      Bits                Hex
                 0   1   2   3   4   7   6   5   4   3   2   1   0
             0                       0   0   0   0   0   0   0   0   0   0
             1       1       1       0   0   0   0   1   0   1   0   0   A
             2                       0   0   0   0   0   0   0   0   0   0
      Rows




             3                       0   0   0   0   0   0   0   0   0   0
             4   1               1   0   0   0   1   0   0   0   1   1   1
             5       1   1   1       0   0   0   0   1   1   1   0   0   E
             6                       0   0   0   0   0   0   0   0   0   0
             7                       0   0   0   0   0   0   0   0   0   0

                                                                             4-14
LCD CG RAM Example
 /* Load user-specific characters into CGRAM                        */
 lcd_write_cmd(0x40);             /* Set CGRAM address counter to 0 */
 p = &UserFont[0][0];
 for (i = 0; i < sizeof(UserFont); i++, p++)
   lcd_putchar (*p);

 lcd_write_cmd(0x80);             /* Set DDRAM address counter to 0 */


/* 8 user defined characters to be loaded into CGRAM (used for
bargraph)      */
const unsigned char UserFont[8][8] = {
  { 0x00,0x0A,0x00,0x00,0x11,0x0e,0x00,0x00 },
  { 0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10 },
  { 0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18 },
  { 0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C },
  { 0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E,0x1E },
  { 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F },
  { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
  { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }
};
                                                                         4-15
LCD CG RAM Example
   Our character has been defined at address 0x00;
   Therefore to display the user defined character
    simply use the lcd_putchar function.

     lcd_putchar (0x00);




                                                      4-16
LCD simulation in uVision
   Add the file Sim.ini to the directory of your current
    project.
   In the Options for target simulator (magic wand icon)
    select the debug tab.




                                                       4-17
LCD simulation in uVision
   Add the file Sim.ini as the Initialization file in the left hand
    panel for the simulator options using the file browser icon.




                                                                       4-18
LCD simulation in uVision
                 The Sim.ini maps the LCD write
                  address to 0x1000000 in
                  memory.
                 By viewing address 0x10000000
                  in the memory window it is
                  possible to simulate the display
                  of the LCD.




                                                4-19
LCD simulation in uVision




              Change display format to Ascii




                                               4-20

								
To top