Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

# lcdconf.h

Go to the documentation of this file.

    00001 /*! \file lcdconf.h \brief Character LCD driver configuration. */
    00002 //*****************************************************************************
    00003 //
    00004 // File Name    : 'lcdconf.h'
    00005 // Title        : Character LCD driver for HD44780/SED1278 displays
    00006 //                  (usable in mem-mapped, or I/O mode)
    00007 // Author       : Pascal Stang - Copyright (C) 2000-2002
    00008 // Created      : 11/22/2000
    00009 // Revised      : 4/30/2002
    00010 // Version      : 1.1
    00011 // Target MCU   : Atmel AVR series
    00012 // Editor Tabs  : 4
    00013 //
    00014 // This code is distributed under the GNU Public License
    00015 //      which can be found at http://www.gnu.org/licenses/gpl.txt
    00016 //
    00017 //*****************************************************************************
    00018
    00019 #ifndef LCDCONF_H
    00020 #define LCDCONF_H
    00021
    00022 // Define type of interface used to access the LCD
    00023 //  LCD_MEMORY_INTERFACE:
    00024 //      To use this mode you must supply the necessary hardware to connect the
    00025 //      LCD to the CPU's memory bus.  The CONTROL and DATA registers of the LCD
    00026 //      (HD44780 chip) must appear in the CPU's memory map.  This mode is faster
    00027 //      than the port interface but requires a little extra hardware to make it
    00028 //      work.  It is especially useful when your CPU is already configured to
    00029 //      use an external memory bus for other purposes (like accessing memory).
    00030 //
    00031 // LCD_PORT_INTERFACE:
    00032 //      This mode allows you to connect the control and data lines of the LCD
    00033 //      directly to the I/O port pins (no interfacing hardware is needed),
    00034 //      but it generally runs slower than the LCD_MEMORY_INTERFACE.
    00035 //      Depending on your needs, when using the LCD_PORT_INTERFACE, the LCD may
    00036 //      be accessed in 8-bit or 4-bit mode.  In 8-bit mode, one whole I/O port
    00037 //      (pins 0-7) is required for the LCD data lines, but transfers are faster.
    00038 //      In 4-bit mode, only I/O port pins 4-7 are needed for data lines, but LCD
    00039 //      access is slower.  In either mode, three additional port pins are
    00040 //      required for the LCD interface control lines (RS, R/W, and E).
    00041
    00042 // Enable one of the following interfaces to your LCD
    00043 //#define LCD_MEMORY_INTERFACE
    00044 #define LCD_PORT_INTERFACE
    00045
    00046 // Enter the parameters for your chosen interface'
    00047 // if you chose the LCD_PORT_INTERFACE:
    00048 #ifdef LCD_PORT_INTERFACE
    00049     #ifndef LCD_CTRL_PORT
    00050         // port and pins you will use for control lines
    00051         #define LCD_CTRL_PORT   PORTC
    00052         #define LCD_CTRL_DDR    DDRC
    00053         #define LCD_CTRL_RS     2
    00054         #define LCD_CTRL_RW     3
    00055         #define LCD_CTRL_E      4
    00056     #endif
    00057     #ifndef LCD_DATA_POUT
    00058         // port you will use for data lines
    00059         #define LCD_DATA_POUT   PORTA
    00060         #define LCD_DATA_PIN    PINA
    00061         #define LCD_DATA_DDR    DDRA
    00062         // access mode you will use (default is 8bit unless 4bit is selected)
    00063         //#define LCD_DATA_4BIT
    00064     #endif
    00065 #endif
    00066
    00067 // if you chose the LCD_MEMORY_INTERFACE:
    00068 #ifdef LCD_MEMORY_INTERFACE
    00069     #ifndef LCD_CTRL_ADDR
    00070         // CPU memory address of the LCD control register
    00071         #define LCD_CTRL_ADDR   0x1000
    00072     #endif
    00073     #ifndef LCD_DATA_ADDR
    00074         // CPU memory address of the LCD data register
    00075         #define LCD_DATA_ADDR   0x1001
    00076     #endif
    00077 #endif
    00078
    00079
    00080 // LCD display geometry
    00081 // change these definitions to adapt settings
    00082 #define LCD_LINES               4   // visible lines
    00083 #define LCD_LINE_LENGTH         20  // line length (in characters)
    00084 // cursor position to DDRAM mapping
    00085 #define LCD_LINE0_DDRAMADDR     0x00
    00086 #define LCD_LINE1_DDRAMADDR     0x40
    00087 #define LCD_LINE2_DDRAMADDR     0x14
    00088 #define LCD_LINE3_DDRAMADDR     0x54
    00089
    00090 // LCD delay
    00091 // This delay affects how quickly accesses are made to the LCD controller.
    00092 // The HD44780 LCD controller requires an access time of at least 1us.
    00093 // LCD_DELAY should be scaled to take at least half that time (500us).
    00094 // Each NOP takes 1 CPU clock cycle to execute.  Thus, at 4MHz, you should
    00095 // use at least 2 NOPs, at 8MHz at least 4 NOPs, etc.
    00096 // You can also use the delay_us(xx) command for longer access times.
    00097
    00098 // LCD_DELAY is now automatically set in lcd.h,
    00099 // however, if you define it here, this definition will override the automatic setting
    00100
    00101 // use this for a fail-safe delay
    00102 //#define LCD_DELAY delay_us(5);
    00103
    00104 #endif