Hm also irgendwo muss ich noch einen Denkfehler haben.
Folgendes Anschlussschemata (am mega8, keinen externen Oszillator oder ähnliches; Intern 1MHz)
LCD-PIN........Bezeichnung..........Anschluss
1..................Gnd.......................Gnd
2..................Vcc........................Vcc
3..................Vee.......................Vee (am Poti)
4..................RS.........................PC4
5..................R/W.......................PD0 (RXD)
6..................Enable....................PC5
7.
8.
9.
10.
11................DB4.......................PC0
12................DB5.......................PC1
13................DB6.......................PC2
14................DB7.......................PC4
main.c
Code:
#include <stdlib.h>
#include <avr/io.h>
#include "lcd.c"
int main(void)
{
lcd_init(LCD_DISP_ON);
lcd_clrscr();
for (;;){
lcd_puts("Test");
}
return 0;
}
lcd.h
Code:
#ifndef LCD_H
#define LCD_H
/*************************************************************************
Title : C include file for the HD44780U LCD library (lcd.c)
Author: Peter Fleury <pfleury@gmx.ch> http://jump.to/fleury
File: $Id: lcd.h,v 1.13.2.2 2006/01/30 19:51:33 peter Exp $
Software: AVR-GCC 3.3
Hardware: any AVR device, memory mapped mode only for AT90S4414/8515/Mega
***************************************************************************/
/**
@defgroup pfleury_lcd LCD library
@code #include <lcd.h> @endcode
@brief Basic routines for interfacing a HD44780U-based text LCD display
Originally based on Volker Oth's LCD library,
changed lcd_init(), added additional constants for lcd_command(),
added 4-bit I/O mode, improved and optimized code.
Library can be operated in memory mapped mode (LCD_IO_MODE=0) or in
4-bit IO port mode (LCD_IO_MODE=1). 8-bit IO port mode not supported.
Memory mapped mode compatible with Kanda STK200, but supports also
generation of R/W signal through A8 address line.
@author Peter Fleury pfleury@gmx.ch http://jump.to/fleury
@see The chapter Interfacing a HD44780 Based LCD to an AVR
on my home page.
*/
/*@{*/
#if (__GNUC__ * 100 + __GNUC_MINOR__) < 303
#error "This library requires AVR-GCC 3.3 or later, update to newer AVR-GCC compiler !"
#endif
#include <inttypes.h>
#include <avr/pgmspace.h>
/**
* @name Definitions for MCU Clock Frequency
* Adapt the MCU clock frequency in Hz to your target.
*/
#define XTAL 8000000 /**< clock frequency in Hz, used to calculate delay timer */
/**
* @name Definition for LCD controller type
* Use 0 for HD44780 controller, change to 1 for displays with KS0073 controller.
*/
#define LCD_CONTROLLER_KS0073 0 /**< Use 0 for HD44780 controller, 1 for KS0073 controller */
/**
* @name Definitions for Display Size
* Change these definitions to adapt setting to your display
*/
#define LCD_LINES 2 /**< number of visible lines of the display */
#define LCD_DISP_LENGTH 16 /**< visibles characters per line of the display */
#define LCD_LINE_LENGTH 0x40 /**< internal line length of the display */
#define LCD_START_LINE1 0x00 /**< DDRAM address of first char of line 1 */
#define LCD_START_LINE2 0x40 /**< DDRAM address of first char of line 2 */
#define LCD_START_LINE3 0x14 /**< DDRAM address of first char of line 3 */
#define LCD_START_LINE4 0x54 /**< DDRAM address of first char of line 4 */
#define LCD_WRAP_LINES 0 /**< 0: no wrap, 1: wrap at end of visibile line */
#define LCD_IO_MODE 1 /**< 0: memory mapped mode, 1: IO port mode */
#if LCD_IO_MODE
/**
* @name Definitions for 4-bit IO mode
* Change LCD_PORT if you want to use a different port for the LCD pins.
*
* The four LCD data lines and the three control lines RS, RW, E can be on the
* same port or on different ports.
* Change LCD_RS_PORT, LCD_RW_PORT, LCD_E_PORT if you want the control lines on
* different ports.
*
* Normally the four data lines should be mapped to bit 0..3 on one port, but it
* is possible to connect these data lines in different order or even on different
* ports by adapting the LCD_DATAx_PORT and LCD_DATAx_PIN definitions.
*
*/
#define LCD_PORT PORTC /**< port for the LCD lines */
#define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */
#define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */
#define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */
#define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */
#define LCD_DATA0_PIN 0 /**< pin for 4bit data bit 0 */
#define LCD_DATA1_PIN 1 /**< pin for 4bit data bit 1 */
#define LCD_DATA2_PIN 2 /**< pin for 4bit data bit 2 */
#define LCD_DATA3_PIN 3 /**< pin for 4bit data bit 3 */
#define LCD_RS_PORT LCD_PORT /**< port for RS line */
#define LCD_RS_PIN 4 /**< pin for RS line */
#define LCD_RW_PORT PORTD /**< port for RW line */
#define LCD_RW_PIN 0 /**< pin for RW line */
#define LCD_E_PORT LCD_PORT /**< port for Enable line */
#define LCD_E_PIN 5 /**< pin for Enable line */
#elif defined(__AVR_AT90S4414__) || defined(__AVR_AT90S8515__) || defined(__AVR_ATmega64__) || \
defined(__AVR_ATmega8515__)|| defined(__AVR_ATmega103__) || defined(__AVR_ATmega128__) || \
defined(__AVR_ATmega161__) || defined(__AVR_ATmega162__)
/*
* memory mapped mode is only supported when the device has an external data memory interface
*/
#define LCD_IO_DATA 0xC000 /* A15=E=1, A14=RS=1 */
#define LCD_IO_FUNCTION 0x8000 /* A15=E=1, A14=RS=0 */
#define LCD_IO_READ 0x0100 /* A8 =R/W=1 (R/W: 1=Read, 0=Write */
#else
#error "external data memory interface not available for this device, use 4-bit IO port mode"
#endif
...
REST Unverändert gelassen
Müsste doch so eigentlich funktionieren oder? Ich habe selbst in der Makefile einmal F_CPU auf 1000000 und auch XTAL auf 1000000 (aus der lcd.h) gesetzt (müsste es eigentlich nicht 1000000UL heißen?), hat aber keinen Effekt - das Display bleibt schwarz.
Viele Grüße,
Simon
Lesezeichen