Forum: Mikrocontroller und Digitale Elektronik Probleme beim ansteuern eines LCD TC1602A-09 + ATMEGA8


von JTR (Gast)


Angehängte Dateien:

Lesenswert?

Also, ich hab hier ein LCD 16*2 und einen ATMEGA 8.
Include verwende ich Peter Fleury's "lcd.h".
Und habe ich die nötigen Einstellungen laut: 
http://www.rn-wissen.de/index.php/LCD-Modul_am_AVR vorgenommen.
Das Ganze soll natürlich im 4-Bit Modus laufen. Bis jetzt bekomme ich 
aber nur 8 Punkte zu sehen. Verkabelt ist, dass ganze wie in dem 
angehängtem Bild. Port ist wirklich PORTC. Die freien Datenleitungen die 
sich im 4-Bit Modus ergeben habe ich nicht auf Masse liegen, oder ist 
das das Problem?
1
/** 
2
 *  @name  Definitions for MCU Clock Frequency
3
 *  Adapt the MCU clock frequency in Hz to your target. 
4
 */
5
#define XTAL 8000000              /**< clock frequency in Hz, used to calculate delay timer */
6
7
8
/**
9
 * @name  Definition for LCD controller type
10
 * Use 0 for HD44780 controller, change to 1 for displays with KS0073 controller.
11
 */
12
#define LCD_CONTROLLER_KS0073 0  /**< Use 0 for HD44780 controller, 1 for KS0073 controller */
13
14
/** 
15
 *  @name  Definitions for Display Size 
16
 *  Change these definitions to adapt setting to your display
17
 */
18
#define LCD_LINES          2    /**< number of visible lines of the display */
19
#define LCD_DISP_LENGTH    16     /**< visibles characters per line of the display */
20
#define LCD_LINE_LENGTH  0x40     /**< internal line length of the display    */
21
#define LCD_START_LINE1  0x00     /**< DDRAM address of first char of line 1 */
22
#define LCD_START_LINE2  0x40     /**< DDRAM address of first char of line 2 */
23
#define LCD_START_LINE3  0x14     /**< DDRAM address of first char of line 3 */
24
#define LCD_START_LINE4  0x54     /**< DDRAM address of first char of line 4 */
25
#define LCD_WRAP_LINES      0     /**< 0: no wrap, 1: wrap at end of visibile line */
26
27
#define LCD_IO_MODE      1         /**< 0: memory mapped mode, 1: IO port mode */
28
#if LCD_IO_MODE
29
/**
30
 *  @name Definitions for 4-bit IO mode
31
 *  Change LCD_PORT if you want to use a different port for the LCD pins.
32
 *
33
 *  The four LCD data lines and the three control lines RS, RW, E can be on the 
34
 *  same port or on different ports. 
35
 *  Change LCD_RS_PORT, LCD_RW_PORT, LCD_E_PORT if you want the control lines on
36
 *  different ports. 
37
 *
38
 *  Normally the four data lines should be mapped to bit 0..3 on one port, but it
39
 *  is possible to connect these data lines in different order or even on different
40
 *  ports by adapting the LCD_DATAx_PORT and LCD_DATAx_PIN definitions.
41
 *  
42
 */
43
#define LCD_PORT         PORTC        /**< port for the LCD lines   */
44
#define LCD_DATA0_PORT   LCD_PORT     /**< port for 4bit data bit 0 */
45
#define LCD_DATA1_PORT   LCD_PORT     /**< port for 4bit data bit 1 */
46
#define LCD_DATA2_PORT   LCD_PORT     /**< port for 4bit data bit 2 */
47
#define LCD_DATA3_PORT   LCD_PORT     /**< port for 4bit data bit 3 */
48
#define LCD_DATA0_PIN    4            /**< pin for 4bit data bit 0  */
49
#define LCD_DATA1_PIN    5            /**< pin for 4bit data bit 1  */
50
#define LCD_DATA2_PIN    6            /**< pin for 4bit data bit 2  */
51
#define LCD_DATA3_PIN    7            /**< pin for 4bit data bit 3  */
52
#define LCD_RS_PORT      LCD_PORT     /**< port for RS line         */
53
#define LCD_RS_PIN       3            /**< pin  for RS line         */
54
#define LCD_RW_PORT      LCD_PORT     /**< port for RW line         */
55
#define LCD_RW_PIN       2            /**< pin  for RW line         */
56
#define LCD_E_PORT       LCD_PORT     /**< port for Enable line     */
57
#define LCD_E_PIN        1            /**< pin  for Enable line     */
58
...


Hier sieht man mein "Programm"
1
#include <avr/io.h>
2
#include <stdint.h>
3
#include <lcd.h>
4
5
DDRC = 0xff;
6
7
int main(void)
8
{
9
   while(1) 
10
   {
11
    /* Initialisiere Display, Cursor aus */
12
    lcd_init(LCD_DISP_ON);
13
14
    /* loesche das LCD Display und Cursor auf 1 Zeile, 1 Spalte */
15
    lcd_clrscr();
16
        
17
    /* String auf Display anzeigen */
18
    lcd_puts("Hello world.");
19
20
   }   
21
}

Ich bekomme gar nichts (bis auf die 8 Blöcke). Es flakert nicht ein 
mal:(.
Kann mir wer weiter helfen?

MFG

von JTR (Gast)


Angehängte Dateien:

Lesenswert?

Fast vergessen.

Ich verwende das AVR Studio 4 und den WIN-AVR GCC Kompiler.
Meine "lcd.c" hab ich dem Projektverzeichis hinzugefügt.

von Sauger (Gast)


Lesenswert?

Hallo,

PORTC beim Mega 8

PC0-5 = ADC0-5
PC6   = RESET
PC7   = ... nicht vorhanden!

mal wieder das Datenblatt ignoriert?

MfG

von JTR (Gast)


Lesenswert?

Ohhhh,
derb.

Danke!!! Werde es gleich probieren :)

von JTR (Gast)


Lesenswert?

Hallo,

also es geht YaY. Aber leider nur die ersten 8 Zeichen :(. Woran kann, 
das liegen?
MFG

von Turbotoni (Gast)


Lesenswert?

Was ist denn nen "YaY" ?
Und welche Software verwendest du?

von andreas (Gast)


Lesenswert?

Hi,
also bei gingen auch mal nur die ersten 8 Stellen.
Bei mir war damals das Display von Pollin defekt.

von JTR (Gast)


Lesenswert?

Na Super :(.

Ja muss mich eh nach einem neuen umschaun weil ich 2*16 Zeichen brauch.

von JTR (Gast)


Lesenswert?

Andere Sache.

Ich arbeite ja mit der Fleury Include. Auf dem Display würde ich gern 
eine Float- Zahl (Gleitkomma) darstellen. Wie gehe ich das an?
Es gibt zwar die Funktion "lcd_puts()", aber die Funktion akzeptiert nur 
Strings.....

von Route_66 (Gast)


Lesenswert?

Das Display ist wahrscheinlich nicht defekt. Es ist entweder falsch 
initialisiert worden oder hat eine ungewöhnliche Anordnung im 
Display-RAM!

Gib einfach mal weiter Zeichen aus. Vielleicht erscheinen sie ja 
iregendwann in der Anzeige.

von Arne (Gast)


Lesenswert?

JTR schrieb:
> Auf dem Display würde ich gern eine Float- Zahl (Gleitkomma) darstellen. > Wie 
gehe ich das an?

s(n)printf(..) vielleicht?
http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/

Und dann mit lcd_puts(..) auf Display, vielleicht?

von JTR (Gast)


Lesenswert?

Gute Alternative! Danke.

Aber die "sprintf" - Funktion is leider sehr speicherintensiv. Beim 
benützen der Funktion sind 60% meines Flash- Speichers weg :(. Mal 
schaun ob sich, das ausgeht.

http://www.c-for-dummies.com/lessons/float2string/

Hier ist dein Vorschlag etwas besser verständlich ;).

MFG

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.