Forum: Mikrocontroller und Digitale Elektronik Probleme mit GLCD


von Max H. (hartl192)


Angehängte Dateien:

Lesenswert?

Ich habe heute für meinen PIC18F45K22 ein Programm geschrieben um ein 
GLCD (KS0108 128x64) anzusteuern. Ich habe die GLCD Bibliothek von 
mikroC for PIC verwendet. Das Bild dass ich anzeigen will wird richtig 
angezeigt, nur wenn ich den Befehl Glcd_Line() oder Glcd_Dot() eingebe 
Zeigt das LCD etwas Falsches an (siehe Bilder). Mit der Funktion 
Glcd_Write_Text() Text ausgeben funktioniert auch.

http://www.mikroe.com/esupport/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=134

Quellcode:
1
// ------------------------------------------------------
2
// GLCD Picture name: SYMS3.BMP
3
// GLCD Model: KS0108 128x64
4
// ------------------------------------------------------
5
6
const code char SYMS3[1024] = {
7
  0,   0,   0, 192,   0,   0,   0,   0, 192,   0,   0, 128,  64,  64,  64,  64,   0,   0, 128,  64,  64, 128, 128,   0,   0,   0,   0,  64, 248,  68,  68,   4,  64,  64,  64, 128,   0,   0,   0, 192,  64,  64,  64,  64, 128,  64,  64,  64,  64, 128,   0, 196,   0,   0, 252,   0,   0, 196,   0,   0,   0,   0,  64,  64,  64, 128,   0,   0, 128, 128,  64,   0,   0,   0,   0,   0, 128,  64,  64,  64,  64, 192,   0,   0,   0, 128,  64,   0, 192,  64,  64,  64,  64, 128,  64,  64,  64,  64, 128,   0, 252,  64,  64,  64, 128,   0,   0,   0, 128,  64,  64,  64, 128,   0,   0,   0, 252,   0,   0, 128,  64,  64,  64,  64,   0,   0,   0,   0,
8
  0,   0,   0,  15,  16,  16,  16,  16,  31,   0,   0,   9,  18,  18,  12,   0,   0,  15,  18,  18,  18,  18,  11,   2,   0,   0,   0,   0,  31,   0,   0,  12,  18,  17,  17,  31,   0,   0,   0,  31,   0,   0,   0,   0,  31,   0,   0,   0,   0,  31,   0,  31,   0,   0,  31,   0,   0,  31,   0,   0,   0,  12,  18,  17,  17,  31,   0,   0,  31,   0,   0,   0,   0,   0,   0,   0,   9,  18,  18,  12,   0, 129, 198,  56,   6,   1,   0,   0,  31,   0,   0,   0,   0,  31,   0,   0,   0,   0,  31,   0,  31,  16,  16,  16,   8,   7,   0,   0,  15,  16,  16,  16,   8,   7,   0,   0,  31,   0,   0,   9,  18,  18,  12,   0,   0,   0,   0,   0,
9
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  64, 224, 240, 240,  96,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 240, 248, 248, 240,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 224, 160,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32, 160, 224,   0,   0,   0,   0,   0,   0,   0,   0,   0,
10
  0,   0,   0,   0,   0, 192, 224, 112,  48,  56, 248, 252, 252, 254, 254, 252, 249, 128,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255, 255, 255, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,  48, 248, 252, 252, 252, 248,  56,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 255,   0,   1,   2,   4, 136, 208,  96,  64,  64,  64,  64,  64,  64,  96, 208, 136,   4,   2,   1,   0, 255,   0,   0,   0,   0,   0,   0,   0,   0,   0,
11
  0,   0,   0,   0,   0,  31,  31,   0,   0, 252, 255, 255, 255, 255, 199,   1,   3,   7,   6,  14,  12,  28,  24,  24,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 128, 192, 192, 224, 240, 240, 248, 248, 252, 255, 255, 255, 255, 254, 252, 248, 248, 240, 240, 224, 192, 192, 128,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 128,   0, 255, 255, 255, 192, 192, 192, 192, 192, 192, 192, 192,   0,   0,   0,   0,   0,   0,   0,   0,  31,  24,  28,  22,  19,  17,  16,  16,  16,  16,  16,  16,  16,  16,  16,  16,  17,  19,  22,  28,  24,  31,   0,   0,   0,   0,   0,   0,   0,   0,   0,
12
  0,   0,   0,   0,   0,   0, 192, 248, 255, 127,  31,   7,   3,   7,  31, 255, 254, 248, 192,   0,   0,   0,   0,   0,   0,   0,   0,   0, 112, 120, 124,  62,  62,  63,  31,  31,  31,  15,  15,  15,   7,   7,   7,   3, 255, 255, 255, 255,   3,   3,   7,   7,   7,  15,  15,  15,  31,  31,  31,  63,  62,  62, 124, 120, 112,   0,   0,   0,   0,   0, 128, 240, 252,  28,   6,   7,   3,   0,  31,  31,  31,  25,  25,  25,  25,  25,  25,  25,  25,  24,  24, 248, 248, 240, 128,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
13
  0,   0,   0,   0,  16,  30,  31,   7,   1,   0,   0,   0,   0,   0,   0,   0,   7,  31,  31,  28,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 128, 128, 192, 224, 255, 255, 127, 255, 240, 224, 192, 128, 128,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   3,  31,  62, 248, 240, 192, 128, 128,   0,   0,   0,   0,   0,   0,   0,   0,   0, 128, 192, 224, 240, 112,   7,  63, 255, 252, 224,  96,  96, 112,  48,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
14
  0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   3,   3,   1,   1,   0,   0,   0,   0,   0,   1,   1,   3,   3,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   1,   1,   1,   3,   3,   3,   6,   6,   6,   6,   7,   7,   3,   3,   3,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0
15
};
16
17
18
19
// Glcd module connections
20
char GLCD_DataPort at PORTD;
21
22
sbit GLCD_CS1 at RB4_bit;
23
sbit GLCD_CS2 at RB3_bit;
24
sbit GLCD_RS  at RB0_bit;
25
sbit GLCD_RW  at RB1_bit;
26
sbit GLCD_EN  at RB2_bit;
27
sbit GLCD_RST at RB5_bit;
28
29
sbit GLCD_CS1_Direction at TRISB4_bit;
30
sbit GLCD_CS2_Direction at TRISB3_bit;
31
sbit GLCD_RS_Direction  at TRISB0_bit;
32
sbit GLCD_RW_Direction  at TRISB1_bit;
33
sbit GLCD_EN_Direction  at TRISB2_bit;
34
sbit GLCD_RST_Direction at TRISB5_bit;
35
// End Glcd module connections
36
37
void delay2S(){                                  // 2 seconds delay function
38
  Delay_ms(2000);
39
}
40
41
void main() {
42
  INTCON=0x00;
43
  
44
  ANSELB=0;
45
  ANSELD=0;
46
  C1ON_bit = 0;                                  // Disable comparators
47
  C2ON_bit = 0;
48
49
  Glcd_Init();                                   // Initialize GLCD
50
  Glcd_Fill(0x00);                               // Clear GLCD
51
  
52
  Glcd_Image(SYMS3);
53
  delay2S();
54
  
55
  Glcd_Fill(0x00);
56
  delay2S();
57
  Glcd_Dot(10,10,1);
58
  delay2S();
59
  Glcd_Line(10,10,50,10,1);
60
}

von Eumel (Gast)


Lesenswert?

Vieleicht ist in besagten Funktionen das Timing zu schnell?

von Max H. (hartl192)


Lesenswert?

Ich habe versucht den Takt des PICs in den Einstellungen zu ändern. 
MikroC glaubt der PIC läuft mit 40MHz in Wirklichkeit läuft er mit 
20MHz. Macht keine unterschied, außer dass die delay2S() 4 Sekunden lang 
dauern

von Max H. (hartl192)


Lesenswert?

Hat jemand eine Idee woran das liegen könnte?

von holger (Gast)


Lesenswert?

>Hat jemand eine Idee woran das liegen könnte?

Ich hätte da schon eine, aber die kann ich nicht belegen
weil dein komplettes Programm nicht zu sehen ist.

Vieleicht möchte deine LIB bei Glcd_Dot(10,10,1);
oder Glcd_Line(10,10,50,10,1);
auch Daten aus dem LCD lesen um einzelne Pixel zu setzen oder
zu löschen. Und du hast die RW Leitung
nicht richtig angeschlossen.

Ist aber nur so eine Idee. Wahrscheinlich Blödsinn;)

von Max H. (hartl192)


Lesenswert?

Weiß jemand wie ich nur einen Dot im LCD setzt ohne die Bibliothek zu 
verwenden um zu Probieren ob es an der Bibliothek oder an der Hardware 
liegt.

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.