TFT monochrom Init

Gast #1914683
Lesenswert?

Hallo,
ich seh den Wald vor lauter Bäumen nicht glaube ich. Ich versuche gerade 
ein TFT-monochrom Display zu initialisieren, erhalte jedoch immer nur 
ein Schneebild und ich weiß nicht woran es liegen könnte.
Ich poste euch hier mal meinen Code sowie die zwei Funktionen auf die 
die Init zugreift und hoffe ihr könnt mir helfen im Anhang befindet sich 
die Initialisierung aus dem Datenblatt. Achja ich programmiere einen 
LPC1768

vielen Dank schoneinmal fürs rübergucken.
1
delayMs(250);  
2
  // Pins für die Displaysteuerung als Ausgänge deklarieren
3
  DDR_MFA_A0    |= (PIN_MFA_A0);
4
  DDR_MFA_D0    |= (PIN_MFA_D0);
5
  DDR_MFA_XRES    |= (PIN_MFA_XRES);
6
  DDR_MFA_XCS    |= (PIN_MFA_XCS);
7
  DDR_MFA_XWR    |= (PIN_MFA_XWR);
8
  DDR_MFA_C86    |= (PIN_MFA_C86);
9
  DDR_MFA_PS    |= (PIN_MFA_PS);
10

11
  // Verzögerung für stabile Spannungsversorgung
12
  delayMs(100);
13
  
14
  // Auf seriellen Übertragungsmodus schalten
15
  PORT_MFA_C86 |= (PIN_MFA_C86);
16
  PORT_MFA_PS &= ~(PIN_MFA_PS);
17

18
  // Chip Select
19
  PORT_MFA_XCS &= ~(PIN_MFA_XCS);
20
    
21
  // Taktleitung 
22
  PORT_MFA_XWR  &= ~(PIN_MFA_XWR);
23

24
  // Reset aufheben
25
  PORT_MFA_XRES |= (PIN_MFA_XRES);
26

27
  // Verzögerung nach Reset-Release
28
  delayMs(250);  
29

30
  // Display aus dem Sleep Mode holen
31
  lcd_send_byte(CMD, 0x11);
32
  delayMs(50);  
33

34

35
  // Column Adress Region setzen
36
  lcd_send_byte(CMD, 0x2A);
37
  lcd_send_byte(PARA, 0x00);
38
  lcd_send_byte(PARA, 0x06);
39
  lcd_send_byte(PARA, 0x00);
40
  lcd_send_byte(PARA, 0x7D);
41

42
  // Page Adress Region setzen
43
  lcd_send_byte(CMD, 0x2B);
44
  lcd_send_byte(PARA, 0x00);
45
  lcd_send_byte(PARA, 0x00);
46
  lcd_send_byte(PARA, 0x00);
47
        lcd_send_byte(PARA, 0xAF);
48

49
  lcd_send_byte(CMD, 0x3A);
50
  lcd_send_byte(PARA, 0x02);
51

52
  delayMs(10);
53

54
  /* Für Landscape-Format eincodieren */
55
  /* -------------------------------- */
56
  // defines LCD_WIDTH & LCD_HEIGHT müssen getauscht werden!
57
  // defines LCD_RAM_PAGES_START_ADDRESS/LCD_RAM_PAGES_END_ADDRESS & LCD_RAM_COLUMNS_START_ADDRESS/LCD_RAM_COLUMNS_END_ADDRESS müssen getauscht werden!
58
  /*
59
  lcd_send_byte(CMD, 0x36);
60
  lcd_send_byte(PARA, 0b01100000);
61

62
  _delay_ms(10);
63
  */
64
        lcd_send_byte(CMD, 0x2D);
65
  lcd_send_byte(PARA, 0x00);   //1
66
        lcd_send_byte(PARA, 0x00);  //2
67
        lcd_send_byte(PARA, 0x00);  //3
68
        lcd_send_byte(PARA, 0x00);  //4
69
        lcd_send_byte(PARA, 0x00);  //5
70
        lcd_send_byte(PARA, 0x00);  //6
71
        lcd_send_byte(PARA, 0x00);  //7
72
        lcd_send_byte(PARA, 0xFF);  
73
        lcd_send_byte(PARA, 0x00);  //1
74
        lcd_send_byte(PARA, 0x00);  //2
75
        lcd_send_byte(PARA, 0x00);  //3
76
        lcd_send_byte(PARA, 0x00);  //4
77
        lcd_send_byte(PARA, 0x00);  //5
78
        lcd_send_byte(PARA, 0x00);  //6
79
        lcd_send_byte(PARA, 0x00);  //7
80
        lcd_send_byte(PARA, 0x00);  //8
81
        lcd_send_byte(PARA, 0x00);  //9
82
        lcd_send_byte(PARA, 0x00);  //10
83
        lcd_send_byte(PARA, 0x00);  //11
84
        lcd_send_byte(PARA, 0x00);  //12
85
        lcd_send_byte(PARA, 0x00);  //13
86
        lcd_send_byte(PARA, 0x00);  //14
87
        lcd_send_byte(PARA, 0x00);  //15
88
        lcd_send_byte(PARA, 0xFF);
89
        lcd_send_byte(PARA, 0x00);  //1
90
        lcd_send_byte(PARA, 0x00);  //2
91
        lcd_send_byte(PARA, 0x00);  //3
92
        lcd_send_byte(PARA, 0x00);  //4
93
        lcd_send_byte(PARA, 0x00);  //5
94
        lcd_send_byte(PARA, 0x00);  //6
95
        lcd_send_byte(PARA, 0x00);  //7
96
        lcd_send_byte(PARA, 0x00);  //8
97
        lcd_send_byte(PARA, 0x00);  //9
98
        lcd_send_byte(PARA, 0x00);  //10
99
        lcd_send_byte(PARA, 0x00);  //11
100
        lcd_send_byte(PARA, 0xFF);
101
        lcd_send_byte(PARA, 0x00);  //1
102
        lcd_send_byte(PARA, 0x00);  //2
103
        lcd_send_byte(PARA, 0x00);  //3
104
        lcd_send_byte(PARA, 0x00);  //4
105
        lcd_send_byte(PARA, 0x00);  //5
106
        lcd_send_byte(PARA, 0x00);  //6
107
        lcd_send_byte(PARA, 0x00);  //7
108
        lcd_send_byte(PARA, 0x00);  //8
109
        lcd_send_byte(PARA, 0x00);  //9
110
        lcd_send_byte(PARA, 0x00);  //10
111
        lcd_send_byte(PARA, 0x00);  //11      
112
        lcd_send_byte(PARA, 0x00);  //12
113

114
        lcd_send_byte(CMD, 0x2C);
115
        delayMs(10);
116

117
        //Taktleitung
118
        PORT_MFA_XWR  |= (PIN_MFA_XWR);
119

120
        // Datenleitung
121
        PORT_MFA_D0   &= ~(PIN_MFA_D0);
122

123
        // CMD+PARA Leitung
124
        PORT_MFA_A0   &= ~(PIN_MFA_A0);
125

126
  // Chip Select
127
  PORT_MFA_XCS |= (PIN_MFA_XCS);
128

129
        // Auf parallele Übertragungsmodus schalten
130
  PORT_MFA_C86 &= ~(PIN_MFA_C86);
131
  PORT_MFA_PS |= (PIN_MFA_PS);
132

133
        // Chip Select
134
  PORT_MFA_XCS &= ~(PIN_MFA_XCS);
135

136
        // Taktleitung
137
        PORT_MFA_XWR &= ~(PIN_MFA_XWR);
138

139
        // CMD+PARA Leitung
140
        PORT_MFA_A0 |= (PIN_MFA_A0);
141

142
        //Sende dots one bit
143
        for (uint16_t y = 0; y <= 1320 ; y++)
144
  {
145
        lcd_send_pixel(0xFF);
146
        lcd_send_pixel(0xFF);
147
        }
148

149
        // Taktleitung
150
        PORT_MFA_XWR  |= (PIN_MFA_XWR);
151

152
        // Datenleitung
153
        PORT_MFA_D0   &= ~(PIN_MFA_D0);
154

155
  // Chip Select
156
  PORT_MFA_XCS |= (PIN_MFA_XCS);
157

158
  // Auf seriellen Übertragungsmodus schalten
159
  PORT_MFA_C86 |= (PIN_MFA_C86);
160
  PORT_MFA_PS &= ~(PIN_MFA_PS);
161
          
162
        // Chip Select
163
  PORT_MFA_XCS &= ~(PIN_MFA_XCS);
164
        
165
        //Taktleitung
166
        PORT_MFA_XWR  &= ~(PIN_MFA_XWR);
167

168
        //Datenleitung
169
        PORT_MFA_D0   |= (PIN_MFA_D0);
170

171
  // Display on  
172
  lcd_send_byte(CMD, 0x29);
173

174

175
void lcd_send_byte(uint8_t u8_Type, uint8_t u8_Byte)
176
{
177
  if (u8_Type == CMD)
178
  {
179
    LCD_COMMAND_MODE();
180
  }
181
  else
182
  {
183
    LCD_PARAMETER_MODE();
184
  }
185
  
186
  // -> Serielle Übertragung des Bytes
187
  for (uint8_t x = 0; x <= 7 ; x++)
188
  {
189
    PORT_MFA_XWR &= ~(PIN_MFA_XWR);
190
    
191
    if (u8_Byte & (1<<(7 - x)))
192
    {
193
      PORT_MFA_D0 |= (PIN_MFA_D0);
194
    }
195
    else
196
    {
197
      PORT_MFA_D0 &= ~(PIN_MFA_D0);
198
    }
199

200
    PORT_MFA_XWR |= (PIN_MFA_XWR);        
201
  }
202

203
}
204

205
void lcd_send_pixel(uint8_t u8_Block)
206
{
207
for (uint8_t x = 0; x <= 7 ; x++)
208
  {
209
    PORT_MFA_XWR &= ~(PIN_MFA_XWR);
210

211
    
212
    if (u8_Block & (1<<(7 - x)))
213
    {
214
      PORT_MFA_D0 |= (PIN_MFA_D0);
215
    }
216
    else
217
    {
218
      PORT_MFA_D0 &= ~(PIN_MFA_D0);
219
    }
220

221
    PORT_MFA_XWR |= (PIN_MFA_XWR);        
222
  }
223
}
Angehängte Dateien:

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren