LCD  1.0
HD44780 compatible lcd driver for Xmega devices
 All Files Functions Variables Macros
Macros | Functions
test_lcd.c File Reference

test file lcd driver for Xmega devices More...

#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>
#include "lcd.h"

Macros

#define F_CPU   2000000UL
 F_CPU must be declared.
 

Functions

void define_unused_data_lines (void)
 Defines unused data lines. More...
 
void define_unused_rw_line (void)
 Defines unused R/W line. More...
 
void lcd_print_mode (void)
 Print LCD mode. More...
 
void lcd_print_busy_flag (void)
 Print if busyflag is used. More...
 
int main (void)
 Main testprogram. More...
 

Detailed Description

test file lcd driver for Xmega devices

Author
Wim Dolman (w.e.dolman@hva.nl)
Date
21-10-2013
Version
1.0

This file contains the test for lcd library. This testprogram can be used for all four modes (4-bit/8-bit,busyfalg/no busyflag) It uses the default settings in lcd.h The data lines are connected to port A. The control lines R/W, RS and E are connect to the pins 3, 4 and 5 of port D. The circuit is in schematic below:

xmega_schematic_test_lcd.png
The default mode is 4-bit with no busyflag. You can changes the mode with the macro's LCD_4BIT_MODE and LCD_BUSY_FLAG in the lcd.h, but in that case you need to recompile both lcd.c and test_lcd.c.

Warning
Be careful using the busyflag. Most alfanumeric displays are 5 Volt devices. Xmega's are not 5 Volt tolerant. When using the busyflag, information is also send from the LCD to the Xmega. So you can damage your Xmega. In this schematic is a 3.3 V LCD used. Add a levelshifter to the data lines if you want to use a 5 V LCD with a busy flag, e.g. the TXB0108 from Texas Instruments.

The schematic below gives an example with a 5 V display without using the busy flag. Input R/W off the display is now connected to the reference.

xmega_schematic_test2_lcd.png
The data lines in lcd.h has to be changed and the 4-bit mode and no busy flag must be selected:

   #define LCD_4BIT_MODE     1
   #define LCD_BUSY_FLAG     0
   #define LCD_DATA_PORT     PORTD
   #define LCD_D4_bp         PIN0_bp
   #define LCD_D5_bp         PIN1_bp
   #define LCD_D6_bp         PIN2_bp
   #define LCD_D7_bp         PIN3_bp
   #define LCD_COMM_PORT     PORTD
   #define LCD_RS_PORT       LCD_COMM_PORT
   #define LCD_E_PORT        LCD_COMM_PORT
   #define LCD_RS_bp         PIN4_bp
   #define LCD_E_bp          PIN5_bp

After changing lcd.h both lcd.c en test_lcd.c must be recompiled.

Function Documentation

void define_unused_data_lines ( void  )

Defines unused data lines.

This function makes unused data lines output and makes this outputs low.

Returns
none
void define_unused_rw_line ( void  )

Defines unused R/W line.

This function makes unused r/w line output and make it low.

Returns
none
void lcd_print_busy_flag ( void  )

Print if busyflag is used.

This function printfs BF is busy flag is used and NO BF if no busyflag is used

Returns
none
void lcd_print_mode ( void  )

Print LCD mode.

This function printf 4 bit if the 4-bit mode is used and 8 bit if the 8-bit mode is used

Returns
none
int main ( void  )

Main testprogram.

This program prints on the first line of the LCD the text "Test" and a number counting from 0 until 999. On the second line it prints the LCD mode and if it uses the busy flag or not.

Returns
none