Hallo, ich habe einen atmega128 an den habe ich nun ein 20x4 zeichen LCD mit einem HD44780 Controller. Leider zeigt das Display nur die erste Zeile, hell die 2. Dunkel, die 3. hell und die 4. dunkel an. Nun hab ich gelesen das man den Controller erst Initialisieren muss aber leider funktioniert das mit meinem Bascom Code nicht.
Ach wie traurig. Und woher denkst du soll jetzt irgend jemand wissen was du falsch machst? Möglichkeiten: a) Programm falsch b) Falsch angeschlossen c) Beides zusammen
NAgeschlossen habe ich es wie hier http://www.rn-wissen.de/index.php/LCD-Modul_am_AVR Der Code in Bascom
1 | '----------------------------------------------------------------------------------------- |
2 | 'name : lcd.bas |
3 | 'copyright : (c) 1995-2005, MCS Electronics |
4 | 'purpose : demo: LCD, CLS, LOWERLINE, SHIFTLCD, SHIFTCURSOR, HOME |
5 | ' CURSOR, DISPLAY |
6 | 'micro : Mega8515 |
7 | 'suited for demo : yes |
8 | 'commercial addon needed : no |
9 | '----------------------------------------------------------------------------------------- |
10 | |
11 | $regfile = "m128def.dat" ' specify the used micro |
12 | $crystal = 4000000 ' used crystal frequency |
13 | $baud = 19200 ' use baud rate |
14 | $hwstack = 32 ' default use 32 for the hardware stack |
15 | $swstack = 10 ' default use 10 for the SW stack |
16 | $framesize = 40 ' default use 40 for the frame space |
17 | |
18 | |
19 | '-------------------------------------------------------------- |
20 | |
21 | ' (c) 1995-2005 MCS Electronics |
22 | |
23 | '-------------------------------------------------------------- |
24 | |
25 | ' file: LCD.BAS |
26 | |
27 | ' demo: LCD, CLS, LOWERLINE, SHIFTLCD, SHIFTCURSOR, HOME |
28 | |
29 | ' CURSOR, DISPLAY |
30 | |
31 | '-------------------------------------------------------------- |
32 | |
33 | |
34 | |
35 | 'note : tested in bus mode with 4-bit on the STK200 |
36 | |
37 | 'LCD - STK200 |
38 | |
39 | '------------------- |
40 | |
41 | 'D4 D4 |
42 | |
43 | 'D5 D5 |
44 | |
45 | 'D6 D6 |
46 | |
47 | 'D7 D7 |
48 | |
49 | 'WR WR |
50 | |
51 | 'E E |
52 | |
53 | 'RS RS |
54 | |
55 | '+5V +5V |
56 | |
57 | 'GND GND |
58 | |
59 | 'V0 V0 |
60 | |
61 | ' D0-D3 are not connected since 4 bit bus mode is used! |
62 | |
63 | |
64 | |
65 | |
66 | |
67 | 'Config Lcdpin = Pin , Db4 = Portb.1 , Db5 = Portb.2 , Db6 = Portb.3 , Db7 = Portb.4 , E = Portb.5 , Rs = Portb.6 |
68 | |
69 | Rem with the config lcdpin statement you can override the compiler settings |
70 | |
71 | |
72 | |
73 | |
74 | |
75 | $lcd = &HC000 |
76 | |
77 | $lcdrs = &H8000 |
78 | |
79 | Config Lcdbus = 8 |
80 | |
81 | |
82 | |
83 | Dim A As Byte |
84 | |
85 | Config Lcd = 20 * 4 'configure lcd screen |
86 | |
87 | 'other options are 16 * 2 , 16 * 4 and 20 * 4, 20 * 2 , 16 * 1a |
88 | |
89 | 'When you dont include this option 16 * 2 is assumed |
90 | |
91 | '16 * 1a is intended for 16 character displays with split addresses over 2 lines |
92 | |
93 | |
94 | |
95 | '$LCD = address will turn LCD into 8-bit databus mode |
96 | |
97 | ' use this with uP with external RAM and/or ROM |
98 | |
99 | ' because it aint need the port pins ! |
100 | |
101 | |
102 | |
103 | Cls 'clear the LCD display |
104 | |
105 | Lcd "Hello world." 'display this at the top line |
106 | |
107 | Wait 1 |
108 | |
109 | Lowerline 'select the lower line |
110 | |
111 | Wait 1 |
112 | |
113 | Lcd "Shift this." 'display this at the lower line |
114 | |
115 | Wait 1 |
116 | |
117 | For A = 1 To 10 |
118 | |
119 | Shiftlcd Right 'shift the text to the right |
120 | |
121 | Wait 1 'wait a moment |
122 | |
123 | Next |
124 | |
125 | |
126 | |
127 | For A = 1 To 10 |
128 | |
129 | Shiftlcd Left 'shift the text to the left |
130 | |
131 | Wait 1 'wait a moment |
132 | |
133 | Next |
134 | |
135 | |
136 | |
137 | Locate 2 , 1 'set cursor position |
138 | |
139 | Lcd "*" 'display this |
140 | |
141 | Wait 1 'wait a moment |
142 | |
143 | |
144 | |
145 | Shiftcursor Right 'shift the cursor |
146 | |
147 | Lcd "@" 'display this |
148 | |
149 | Wait 1 'wait a moment |
150 | |
151 | |
152 | |
153 | Home Upper 'select line 1 and return home |
154 | |
155 | Lcd "Replaced." 'replace the text |
156 | |
157 | Wait 1 'wait a moment |
158 | |
159 | |
160 | |
161 | Cursor Off Noblink 'hide cursor |
162 | |
163 | Wait 1 'wait a moment |
164 | |
165 | Cursor On Blink 'show cursor |
166 | |
167 | Wait 1 'wait a moment |
168 | |
169 | Display Off 'turn display off |
170 | |
171 | Wait 1 'wait a moment |
172 | |
173 | Display On 'turn display on |
174 | |
175 | '-----------------NEW support for 4-line LCD------ |
176 | |
177 | Thirdline |
178 | |
179 | Lcd "Line 3" |
180 | |
181 | Fourthline |
182 | |
183 | Lcd "Line 4" |
184 | |
185 | Home Third 'goto home on line three |
186 | |
187 | Home Fourth |
188 | |
189 | Home F 'first letteer also works |
190 | |
191 | Locate 4 , 1 : Lcd "Line 4" |
192 | |
193 | Wait 1 |
>NAgeschlossen habe ich es wie hier >http://www.rn-wissen.de/index.php/LCD-Modul_am_AVR Fein, dann hast du es im 8Bit Modus angeschlossen und versuchst es im 4Bit Modus zu programmieren. Das geht natürlich nicht.
>und wie kann ich das im 8bit Modus programmieren?
Mit den Codebeispielen von der Seite?
ICh hab schon diverse codes von verschiedenen Seiten versucht aber alles funktioniert nicht
>ICh hab schon diverse codes von verschiedenen Seiten versucht aber alles >funktioniert nicht Vielleicht weniger Copy&Paste mit irgendwelchen Codes von irgendwelchen Seiten und mehr NAchdenken und Mitdenken?
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
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.