Display EA-DOGM 132x32 Steuerung SPI mit AT90USB1287

OP #3369883
Lesenswert?

Hallo an Alle,
folgendes, ich könnte nur schwarzes Display sehen, ich poste meinen 
Code:
1
#include <stdio.h>
2
#include <math.h>
3

4

5
#include <avr/io.h>
6
#include <avr/interrupt.h>
7
#include <avr/pgmspace.h>
8
#include <inttypes.h>
9
#include <avr/delay.h>
10

11

12
uint8_t topview = 1;
13
uint8_t xoffset;
14

15

16

17
void SwDelay(  long time);
18
void InitLCD(void);
19
void byteout(  char value);
20
void SPI_MasterTransmit( char cmd);
21
void ClearLCD(void);
22
void SetContrast(  char contrast);
23
void SetPageAddress( char page);
24
void SetColumnAddress(char column);
25
void WriteLcdData( char data);
26
void DrawChar( char ascii,int row, int column);
27
void DrawString(char* string,int column);
28
void PaintChar(char array[],int row,int column);
29
//  char GetTextEffect(void);
30
void SetTextEffect(  char status);
31
void DrawSegmentedString(  char* string,  char origin,  char final,int column);
32
void DrawImage(const   char logo[][4]);
33

34
typedef union
35
{
36
    char word;    // 1 Word
37
  
38
  struct
39
  {
40
    
41
      char bit0:1;
42
      char bit1:1;
43
      char bit2:1;
44
      char bit3:1;
45
      char bit4:1;
46
      char bit5:1;
47
      char bit6:1;
48
      char bit7:1;
49
  }bits;
50
  
51
}BYTE;
52

53

54
//#endif /*GRAPHICLCD_H_*/
55

56
const   char ATRUNTIME_LOGO[132][4]={
57
  {0b00000000,0b00000000,0b00000000,0b00000000},
58
  {0b00000000,0b00000000,0b00000000,0b00000000},
59
  {0b00000000,0b00000000,0b00000000,0b00000000},
60
  {0b00000000,0b00000000,0b00000000,0b00000000},
61
  {0b00000000,0b00000000,0b00000000,0b00000000},
62
  {0b00000000,0b00000000,0b00000000,0b00000000},
63
  {0b00000000,0b00000000,0b00000000,0b00000000},
64
  {0b00000000,0b00000000,0b00000000,0b00000000},
65
  {0b00011100,0b00111100,0b00000000,0b00011100},
66
  {0b00011100,0b01111110,0b01110000,0b00011100},
67
  {0b00011100,0b01111111,0b00111000,0b00011100},
68
  {0b00011100,0b01110011,0b00111000,0b00011100},
69
  {0b00011100,0b01110011,0b00111000,0b00011100},
70
  {0b00011100,0b01110011,0b00111000,0b00011100},
71
  {0b00011100,0b00111011,0b00111000,0b00011100},
72
  {0b00011100,0b01111111,0b11111000,0b00011100},
73
  {0b00011100,0b01111111,0b11110000,0b00011100},
74
  {0b00011100,0b01111111,0b11100000,0b00011100},
75
  {0b00011100,0b00000000,0b00000000,0b00011100},
76
  {0b00011100,0b00000000,0b00000000,0b00011100},
77
  {0b00011100,0b00000000,0b00000000,0b00011100},
78
  {0b00011100,0b00000000,0b00111000,0b00011100},
79
  {0b00011100,0b00000000,0b00111000,0b00011100},
80
  {0b00011100,0b00000000,0b00111000,0b00011100},
81
  {0b00011100,0b00011111,0b11111111,0b00011100},
82
  {0b00011100,0b00111111,0b11111111,0b10011100},
83
  {0b00011100,0b01111111,0b11111111,0b10011100},
84
  {0b00011100,0b01110000,0b00111000,0b00011100},
85
  {0b00011100,0b01110000,0b00111000,0b00011100},
86
  {0b00011100,0b01110000,0b00111000,0b00011100},
87
  {0b00011100,0b01110000,0b00111000,0b00011100},
88
  {0b00011100,0b01110000,0b00111000,0b00011100},
89
  {0b00011100,0b00000000,0b00000000,0b00011100},
90
  {0b00011100,0b00000000,0b00000000,0b00011100},
91
  {0b00011100,0b00000000,0b00000000,0b00011100},
92
  {0b00011100,0b01111111,0b11111000,0b00011100},
93
  {0b00011100,0b01111111,0b11111000,0b00011100},
94
  {0b00011100,0b01111111,0b11111000,0b00011100},
95
  {0b00011100,0b00000000,0b01110000,0b00011100},
96
  {0b00011100,0b00000000,0b00111000,0b00011100},
97
  {0b00011100,0b00000000,0b00111000,0b00011100},
98
  {0b00011100,0b00000000,0b00111000,0b00011100},
99
  {0b00011100,0b00000000,0b11111000,0b00011100},
100
  {0b00011100,0b00000000,0b11110000,0b00011100},
101
  {0b00011100,0b00000000,0b11100000,0b00011100},
102
  {0b00011100,0b00000000,0b00000000,0b00011100},
103
  {0b00011100,0b00000000,0b00000000,0b00011100},
104
  {0b00011100,0b00000000,0b00000000,0b00011100},
105
  {0b00011100,0b00011111,0b11111000,0b00011100},
106
  {0b00011100,0b00111111,0b11111000,0b00011100},
107
  {0b00011100,0b01111111,0b11111000,0b00011100},
108
  {0b00011100,0b01110000,0b00000000,0b00011100},
109
  {0b00011100,0b01110000,0b00000000,0b00011100},
110
  {0b00011100,0b01110000,0b00000000,0b00011100},
111
  {0b00011100,0b00111000,0b00000000,0b00011100},
112
  {0b00011100,0b01111111,0b11111000,0b00011100},
113
  {0b00011100,0b01111111,0b11111000,0b00011100},
114
  {0b00011100,0b01111111,0b11111000,0b00011100},
115
  {0b00011100,0b00000000,0b00000000,0b00011100},
116
  {0b00011100,0b00000000,0b00000000,0b00011100},
117
  {0b00011100,0b00000000,0b00000000,0b00011100},
118
  {0b00011100,0b01111111,0b11111000,0b00011100},
119
  {0b00011100,0b01111111,0b11111000,0b00011100},
120
  {0b00011100,0b01111111,0b11111000,0b00011100},
121
  {0b00011100,0b00000000,0b01110000,0b00011100},
122
  {0b00011100,0b00000000,0b00111000,0b00011100},
123
  {0b00011100,0b00000000,0b00111000,0b00011100},
124
  {0b00011100,0b00000000,0b00111000,0b00011100},
125
  {0b00011100,0b01111111,0b11111000,0b00011100},
126
  {0b00011100,0b01111111,0b11110000,0b00011100},
127
  {0b00011100,0b01111111,0b11100000,0b00011100},
128
  {0b00011100,0b00000000,0b00000000,0b00011100},
129
  {0b00011100,0b00000000,0b00000000,0b00011100},
130
  {0b00011100,0b00000000,0b00111000,0b00011100},
131
  {0b00011100,0b00000000,0b00111000,0b00011100},
132
  {0b00011100,0b00000000,0b00111000,0b00011100},
133
  {0b00011100,0b00011111,0b11111111,0b00011100},
134
  {0b00011100,0b00111111,0b11111111,0b10011100},
135
  {0b00011100,0b01111111,0b11111111,0b10011100},
136
  {0b00011100,0b01110000,0b00111000,0b00011100},
137
  {0b00011100,0b01110000,0b00111000,0b00011100},
138
  {0b00011100,0b01110000,0b00111000,0b00011100},
139
  {0b00011100,0b01110000,0b00111000,0b00011100},
140
  {0b00011100,0b01110000,0b00111000,0b00011100},
141
  {0b00011100,0b00000000,0b00000000,0b00011100},
142
  {0b00011100,0b00000000,0b00000000,0b00011100},
143
  {0b00011100,0b00000000,0b00000000,0b00011100},
144
  {0b00011100,0b01110000,0b00111000,0b00011100},
145
  {0b00011100,0b01110000,0b00111000,0b00011100},
146
  {0b00011100,0b01110000,0b00111001,0b10011100},
147
  {0b00011100,0b01111111,0b11111001,0b10011100},
148
  {0b00011100,0b01111111,0b11111001,0b10011100},
149
  {0b00011100,0b01111111,0b11111001,0b10011100},
150
  {0b00011100,0b01110000,0b00000000,0b00011100},
151
  {0b00011100,0b01110000,0b00000000,0b00011100},
152
  {0b00011100,0b01110000,0b00000000,0b00011100},
153
  {0b00011100,0b01110000,0b00000000,0b00011100},
154
  {0b00011100,0b00000000,0b00000000,0b00011100},
155
  {0b00011100,0b01111111,0b11111000,0b00011100},
156
  {0b00011100,0b01111111,0b11111000,0b00011100},
157
  {0b00011100,0b01111111,0b11111000,0b00011100},
158
  {0b00011100,0b00000000,0b01110000,0b00011100},
159
  {0b00011100,0b00000000,0b00111000,0b00011100},
160
  {0b00011100,0b01111111,0b11111000,0b00011100},
161
  {0b00011100,0b01111111,0b11111000,0b00011100},
162
  {0b00011100,0b01111111,0b11110000,0b00011100},
163
  {0b00011100,0b00000000,0b01110000,0b00011100},
164
  {0b00011100,0b00000000,0b00111000,0b00011100},
165
  {0b00011100,0b01111111,0b11111000,0b00011100},
166
  {0b00011100,0b01111111,0b11111000,0b00011100},
167
  {0b00011100,0b01111111,0b11110000,0b00011100},
168
  {0b00011100,0b00000000,0b00000000,0b00011100},
169
  {0b00011100,0b00001111,0b11000000,0b00011100},
170
  {0b00011100,0b00011111,0b11100000,0b00011100},
171
  {0b00011100,0b00111111,0b11110000,0b00011100},
172
  {0b00011100,0b01111011,0b01111000,0b00011100},
173
  {0b00011100,0b01110011,0b00111000,0b00011100},
174
  {0b00011100,0b01110011,0b00111000,0b00011100},
175
  {0b00011100,0b01110011,0b00111000,0b00011100},
176
  {0b00011100,0b01110011,0b01111000,0b00011100},
177
  {0b00011100,0b01110011,0b11110000,0b00011100},
178
  {0b00011100,0b00111011,0b11110000,0b00011100},
179
  {0b00011100,0b00000011,0b11000000,0b00011100},
180
  {0b00000000,0b00000000,0b00000000,0b00000000},
181
  {0b00000000,0b00000000,0b00000000,0b00000000},
182
  {0b00000000,0b00000000,0b00000000,0b00000000},
183
  {0b00000000,0b00000000,0b00000000,0b00000000},
184
  {0b00000000,0b00000000,0b00000000,0b00000000},
185
  {0b00000000,0b00000000,0b00000000,0b00000000},
186
  {0b00000000,0b00000000,0b00000000,0b00000000},
187
  {0b00000000,0b00000000,0b00000000,0b00000000},
188
  {0b00000000,0b00000000,0b00000000,0b00000000}
189
};
190

191
/*HERE STARTS SMALL FONT DEFINITION*/
192
  char char_full[5]={
193
  
194
  {0xFF} ,
195
  {0xFF} ,
196
  {0xFF} ,
197
  {0xFF} ,
198
  {0xFF}
199

200
};
201

202
  char char_cursor[5]={
203
  {0x40},
204
  {0x40},
205
  {0x40},
206
  {0x40},
207
  {0x40}
208
};
209

210
  char char_space[5]={
211
  {0x00},
212
  {0x00},
213
  {0x00},
214
  {0x00},
215
  {0x00}
216
};
217

218
  char char_apostrophe[5]={
219
  {0x00},
220
  {0x05},
221
  {0x03},
222
  {0x00},
223
  {0x00}
224
};
225

226
  char char_quotation[5]={
227
  {0x00},
228
  {0x43},
229
  {0x00},
230
  {0x43},
231
  {0x00}
232
};
233

234

235
  char char_comma[5]={
236
  {0x00},
237
  {0x50},
238
  {0x30},
239
  {0x00},
240
  {0x00}
241
};
242

243
  char char_exclamation[5]={
244
  {0x00},
245
  {0x00},
246
  {0x4F},
247
  {0x00},
248
  {0x00}
249
};
250
  char char_dash[5]={
251
  {0x08},
252
  {0x08},
253
  {0x08},
254
  {0x08},
255
  {0x08}
256
};
257

258
  char char_period[5]={
259
  {0x00},
260
  {0x60},
261
  {0x60},
262
  {0x00},
263
  {0x00}
264
};
265

266
  char char_question[5]={
267
  {0x02},
268
  {0x01},
269
  {0x51},
270
  {0x09},
271
  {0x06}
272
};
273

274
  char char_0[5]={
275
  {0x3E},
276
  {0x51},
277
  {0x49},
278
  {0x45},
279
  {0x3E}
280
};
281
  char char_1[5]={
282
  {0x00},
283
  {0x42},
284
  {0x7F},
285
  {0x40},
286
  {0x00}
287
};
288

289
  char char_2[5]={
290
  {0x42},
291
  {0x61},
292
  {0x51},
293
  {0x49},
294
  {0x46}
295
  };     char char_3[5]={
296
  {0x21},
297
  {0x41},
298
  {0x45},
299
  {0x4B},
300
  {0x31}
301
};
302

303
  char char_4[5]={
304
  {0x18},
305
  {0x14},
306
  {0x12},
307
  {0x7F},
308
  {0x10}
309
};
310

311
  char char_5[5]={
312
  {0x27},
313
  {0x45},
314
  {0x45},
315
  {0x45},
316
  {0x39}
317
};
318

319
  char char_6[5]={
320
  {0x3C},
321
  {0x4A},
322
  {0x49},
323
  {0x49},
324
  {0x30}
325
};
326

327
  char char_7[5]={
328
  {0x01},
329
  {0x71},
330
  {0x09},
331
  {0x05},
332
  {0x03}
333
};
334

335
  char char_8[5]={
336
  {0x36},
337
  {0x49},
338
  {0x49},
339
  {0x49},
340
  {0x36}
341
};
342

343
  char char_9[5] ={
344
  {0x06},
345
  {0x49},
346
  {0x49},
347
  {0x29},
348
  {0x1E}
349
};
350

351
  char char_right[5] ={
352
  {0x08},
353
  {0x08},
354
  {0x2A},
355
  {0x1C},
356
  {0x08}
357
};
358

359
  char char_left[5] ={
360
  {0x08},
361
  {0x1C},
362
  {0x2A},
363
  {0x08},
364
  {0x08}
365
};
366

367
  char char_a[5] ={
368
  {0x7E},
369
  {0x11},
370
  {0x11},
371
  {0x11},
372
  {0x7E}
373
};
374

375
  char char_b[5] ={
376
  {0x7F},
377
  {0x49},
378
  {0x49},
379
  {0x49},
380
  {0x36}
381
};
382
  char char_c[5] ={
383
  {0x3E},
384
  {0x41},
385
  {0x41},
386
  {0x41},
387
  {0x22}
388
};
389

390
  char char_colon[5] ={
391
  {0x00},
392
  {0x36},
393
  {0x36},
394
  {0x00},
395
  {0x00}
396
};
397
  char char_d[5] ={
398
  {0x7F},
399
  {0x41},
400
  {0x41},
401
  {0x22},
402
  {0x1C}
403
};
404

405
  char char_e[5] ={
406
  {0x7F},
407
  {0x49},
408
  {0x49},
409
  {0x49},
410
  {0x41}
411
};
412

413
  char char_f[5] ={
414
  {0x7F},
415
  {0x09},
416
  {0x09},
417
  {0x09},
418
  {0x01}
419
};
420

421
  char char_g[5] ={
422
  {0x3E},
423
  {0x41},
424
  {0x49},
425
  {0x49},
426
  {0x7A}
427
};
428

429
  char char_h[5] ={
430
  {0x7F},
431
  {0x08},
432
  {0x08},
433
  {0x08},
434
  {0x7F}
435
};
436

437
  char char_i[5] ={
438
  {0x00},
439
  {0x41},
440
  {0x7F},
441
  {0x41},
442
  {0x00}
443
};
444

445
  char char_j[5] ={
446
  {0x20},
447
  {0x40},
448
  {0x41},
449
  {0x3F},
450
  {0x01}
451
};
452

453
  char char_k[5] ={
454
  {0x7F},
455
  {0x08},
456
  {0x14},
457
  {0x22},
458
  {0x41}
459
};
460

461
  char char_l[5] ={
462
  {0x7F},
463
  {0x40},
464
  {0x40},
465
  {0x40},
466
  {0x40}
467
};
468

469
  char char_m[5] ={
470
  {0x7F},
471
  {0x02},
472
  {0x0C},
473
  {0x02},
474
  {0x7F}
475
};
476

477
  char char_n[5] ={
478
  {0x7F},
479
  {0x04},
480
  {0x08},
481
  {0x10},
482
  {0x7F}
483
};
484

485
  char char_o[5] ={
486
  {0x3E},
487
  {0x41},
488
  {0x41},
489
  {0x41},
490
  {0x3E}
491
};
492

493
  char char_p[5] ={
494
  {0x7F},
495
  {0x09},
496
  {0x09},
497
  {0x09},
498
  {0x06}
499
};
500

501
  char char_q[5] ={
502
  {0x3E},
503
  {0x41},
504
  {0x51},
505
  {0x21},
506
  {0x5E}
507
};
508

509
  char char_r[5] ={
510
  {0x7F},
511
  {0x09},
512
  {0x19},
513
  {0x29},
514
  {0x46}
515
};
516

517
  char char_s[5] ={
518
  {0x46},
519
  {0x49},
520
  {0x49},
521
  {0x49},
522
  {0x31}
523
};
524

525
  char char_t[5] ={
526
  {0x01},
527
  {0x01},
528
  {0x7F},
529
  {0x01},
530
  {0x01}
531
};
532

533
  char char_u[5] ={
534
  {0x3F},
535
  {0x40},
536
  {0x40},
537
  {0x40},
538
  {0x3F}
539
};
540
  char char_v[5] ={
541
  {0x1F},
542
  {0x20},
543
  {0x40},
544
  {0x20},
545
  {0x1F}
546
};
547

548
  char char_w[5] ={
549
  {0x3F},
550
  {0x40},
551
  {0x30},
552
  {0x40},
553
  {0x3F}
554
};
555
  char char_x[5] ={
556
  {0x63},
557
  {0x14},
558
  {0x08},
559
  {0x14},
560
  {0x63}
561
};
562

563
  char char_y[5] ={
564
  {0x43},
565
  {0x08},
566
  {0x70},
567
  {0x08},
568
  {0x07}
569
};
570

571
  char char_z[5] ={
572
  {0x61},
573
  {0x51},
574
  {0x49},
575
  {0x45},
576
  {0x43}
577
};
578

579
//volatile   char text_effect;
580

581
void SwDelay(  long time)
582
{
583
  while(time--);
584
}
585

586

587
void ClearLCD(void)
588
{
589
  volatile   short i;
590

591
  SetPageAddress(0);
592
  SetColumnAddress(0);
593
  
594
  for(i=0;i<132;i++)
595
  {
596
    WriteLcdData(0x00);
597
  }
598
  
599
  SetPageAddress(1);
600
  SetColumnAddress(0);
601
  
602
  for(i=0;i<132;i++)
603
  {
604
    WriteLcdData(0x00);
605
  }
606
  
607
  SetPageAddress(2);
608
  SetColumnAddress(0);
609
  
610
  for(i=0;i<132;i++)
611
  {
612
    WriteLcdData(0x00);
613
  }
614
  
615
  SetPageAddress(3);
616
  SetColumnAddress(0);
617
  
618
  for(i=0;i<132;i++)
619
  {
620
    WriteLcdData(0x00);
621
  }
622
}
623

624
/*0 to 64  (30 is ok) */
625
void SetContrast(  char contrast)
626
{
627
  SPI_MasterTransmit(0x81);
628
  SPI_MasterTransmit(contrast);
629

630
}
631

632
void SetPageAddress( char page)
633
{
634
  SPI_MasterTransmit(0xB0+page);
635
}
636

637
void SetColumnAddress( char column)
638
{
639
  SPI_MasterTransmit(0x10+((0xf0&column)>>4));
640

641
  SPI_MasterTransmit(0x00+(0x0f&column));
642
}
643

644
void WriteLcdData( char data)
645
{
646
  SPI_MasterTransmit(data);
647
}
648

649

650
void DrawString(char* string,int column)
651
{
652
  volatile int index=0;
653
  while(*string!='\0')
654
  {
655
    DrawChar(*string,index,column);
656
    string++;
657
    index++;
658
  }
659
}
660

661
void DrawSegmentedString(  char* string,  char origin,  char final,int column)
662
{
663
  volatile int index;
664
  for(index=origin;index<final;index++)
665
  {
666
    if(*string!='\0')
667
    {
668
      DrawChar(*string,index,column);
669
      string++;
670
    }
671
    else
672
    break;
673
  }
674
}
675

676
void DrawChar( char ascii,int row, int column)
677
{
678
  switch(ascii)
679
  {
680

681
    case '_':
682
    PaintChar(char_cursor,row,column);
683
    break;
684

685
    case '?':
686
    PaintChar(char_question,row,column);
687
    break;
688

689
    case '\'':
690
    PaintChar(char_apostrophe,row,column);
691
    break;
692

693
    case '\"':
694
    PaintChar(char_quotation,row,column);
695
    break;
696

697
    case '!':
698
    PaintChar(char_exclamation,row,column);
699
    break;
700

701
    case ',':
702
    PaintChar(char_comma,row,column);
703
    break;
704

705
    case ' ':
706
    PaintChar(char_space,row,column);
707
    break;
708

709
    case '-':
710
    PaintChar(char_dash,row,column);
711
    break;
712

713
    case '<':
714
    PaintChar(char_left,row,column);
715
    break;
716

717
    case '>':
718
    PaintChar(char_right,row,column);
719
    break;
720

721
    case ':':
722
    PaintChar(char_colon,row,column);
723
    break;
724

725
    case '.':
726
    PaintChar(char_period,row,column);
727
    break;
728

729
    case '0':
730
    PaintChar(char_0,row,column);
731
    break;
732

733
    case '1':
734
    PaintChar(char_1,row,column);
735
    break;
736

737
    case '2':
738
    PaintChar(char_2,row,column);
739
    break;
740

741
    case '3':
742
    PaintChar(char_3,row,column);
743
    break;
744

745
    case '4':
746
    PaintChar(char_4,row,column);
747
    break;
748

749
    case '5':
750
    PaintChar(char_5,row,column);
751
    break;
752

753
    case '6':
754
    PaintChar(char_6,row,column);
755
    break;
756

757
    case '7':
758
    PaintChar(char_7,row,column);
759
    break;
760

761
    case '8':
762
    PaintChar(char_8,row,column);
763
    break;
764

765
    case '9':
766
    PaintChar(char_9,row,column);
767
    break;
768

769
    case 'A':
770
    PaintChar(char_a,row,column);
771
    break;
772

773
    case 'B':
774
    PaintChar(char_b,row,column);
775
    break;
776

777
    case 'C':
778
    PaintChar(char_c,row,column);
779
    break;
780

781
    case 'D':
782
    PaintChar(char_d,row,column);
783
    break;
784

785
    case 'E':
786
    PaintChar(char_e,row,column);
787
    break;
788

789
    case 'F':
790
    PaintChar(char_f,row,column);
791
    break;
792

793
    case 'G':
794
    PaintChar(char_g,row,column);
795
    break;
796

797
    case 'H':
798
    PaintChar(char_h,row,column);
799
    break;
800

801
    case 'I':
802
    PaintChar(char_i,row,column);
803
    break;
804

805
    case 'J':
806
    PaintChar(char_j,row,column);
807
    break;
808

809
    case 'K':
810
    PaintChar(char_k,row,column);
811
    break;
812

813
    case 'L':
814
    PaintChar(char_l,row,column);
815
    break;
816

817
    case 'M':
818
    PaintChar(char_m,row,column);
819
    break;
820

821
    case 'N':
822
    PaintChar(char_n,row,column);
823
    break;
824

825
    case 'O':
826
    PaintChar(char_o,row,column);
827
    break;
828

829
    case 'P':
830
    PaintChar(char_p,row,column);
831
    break;
832

833
    case 'Q':
834
    PaintChar(char_q,row,column);
835
    break;
836

837
    case 'R':
838
    PaintChar(char_r,row,column);
839
    break;
840
    
841
    case 'S':
842
    PaintChar(char_s,row,column);
843
    break;
844

845
    case 'T':
846
    PaintChar(char_t,row,column);
847
    break;
848

849
    case 'U':
850
    PaintChar(char_u,row,column);
851
    break;
852

853
    case 'V':
854
    PaintChar(char_v,row,column);
855
    break;
856

857
    case 'W':
858
    PaintChar(char_w,row,column);
859
    break;
860

861
    case 'X':
862
    PaintChar(char_x,row,column);
863
    break;
864

865
    case 'Y':
866
    PaintChar(char_y,row,column);
867
    break;
868

869
    case 'Z':
870
    PaintChar(char_z,row,column);
871
    break;
872
    
873
    default :
874
    PaintChar(char_full,row,column);
875
  }
876

877
}
878

879
void PaintChar(char array[],int row,int column)
880
{
881
  volatile int i;
882

883
  SetPageAddress(column);
884
  SetColumnAddress(row*6);
885
  
886
  WriteLcdData(array[i]);
887
  WriteLcdData(0x00);
888
//
889
  //if(GetTextEffect()==0)
890
  //{
891
    //for(i=0;i<5;i++)
892
    //{
893
      //WriteLcdData(array[i]);
894
    //}
895
    //WriteLcdData(0x00);
896
  //}
897
  //else
898
  //{
899
    //for(i=0;i<5;i++)
900
    //{
901
      //WriteLcdData(~array[i]);
902
    //}
903
    //WriteLcdData(~0x00);
904
  //}
905
//}
906

907
//void SetTextEffect(  char status)
908
//{
909
  //text_effect=status;
910
//}
911
//
912
//  char GetTextEffect(void)
913
//{
914
  //return text_effect;
915
}
916

917
void DrawImage(const   char logo[][4])
918
{
919
  int i;
920
  SetContrast(30);
921
  
922
  SetPageAddress(0);
923
  SetColumnAddress(0);
924
  for(i=0;i<132;i++)
925
  { WriteLcdData(logo[i][3]);}
926
  SetPageAddress(1);
927
  SetColumnAddress(0);
928
  for(i=0;i<132;i++)
929
  {WriteLcdData(logo[i][2]);}
930
  SetPageAddress(2);
931
  SetColumnAddress(0);
932
  for(i=0;i<132;i++)
933
  {WriteLcdData(logo[i][1]);}
934
  SetPageAddress(3);
935
  SetColumnAddress(0);
936
  for(i=0;i<132;i++)
937
  {WriteLcdData(logo[i][0]);}
938
  
939
}
940

941
void SPI_MasterInit(void)
942
{
943
  
944
  /* Clock Polarity & Clock Phase */
945
  //PORTB &= ~((1 << MEINBIT0) | (1 << MEINBIT2)); // löscht Bit 0 und 2 in PORTB
946
    SPCR  &= ~((1 <<CPOL     ) | (1 << CPHA    ));
947
  
948
  /* Set MOSI and SCK output, all others input */
949
  //PORTB |= ((1 << MEINBIT0) | (1 << MEINBIT2)); // setzt Bit 0 und 2 in PORTB auf "1"
950
    DDRB  |= ((1 << DDB2    ) | (1 << DDB1    ));
951
  
952
  /* Enable SPI, Master, set clock rate fck/16 */
953
   SPCR   |= ((1<<SPE)|(1<<MSTR)|(1<<SPR0));
954
}
955
void SPI_MasterTransmit(char cData)
956
{
957
  PORTB &= ~(1<<PB0);
958
  /* Start transmission */
959
  SPDR = cData;
960
  /* Wait for transmission complete */
961
  while(!(SPSR & (1<<SPIF)))
962
  ;
963
  PORTB |= (1<<PB0);
964
}
965

966
//* Init Display
967
//*
968
void dogm_init(void)
969
{
970
  SPI_MasterTransmit(0x40); 
971
  SPI_MasterTransmit(0xA1);
972
  SPI_MasterTransmit(0xC0);
973
  SPI_MasterTransmit(0xA6);
974
  SPI_MasterTransmit(0xA2);
975
  SPI_MasterTransmit(0x2F);
976
  SPI_MasterTransmit(0xF8);
977
  SPI_MasterTransmit(0x00);
978
  SPI_MasterTransmit(0x23);
979
  SPI_MasterTransmit(0x81);
980
  SPI_MasterTransmit(0x1F);
981
  SPI_MasterTransmit(0xAC);
982
  SPI_MasterTransmit(0x00);
983
  SPI_MasterTransmit(0xAF);
984
}
985

986

987
int  main(void) 
988
{
989
  // start up the LCD
990
  DDRA |= (1<<DDA2); //Set the pins as output
991
  DDRB |= (1<<DDB0); 
992
  DDRD = 0x01;
993
  DDRF = 0x03;
994

995
  //PORTD |= (1<<PD0);
996
  
997
  //Reset
998
  PORTD &= ~(1<<PD0);
999
  _delay_ms(1000);
1000
  PORTD |= (1<<PD0);
1001
  
1002
  // Chip Select
1003
  //PORTB &= ~(1<<PB0);
1004

1005
  PORTA &= ~(1<<PA2);
1006
  // spi configuring
1007
  SPI_MasterInit();
1008
  _delay_ms(50);
1009
  
1010
  
1011
  // Init LCD
1012
  dogm_init();
1013
  _delay_ms(50);
1014
  
1015
  
1016
  // Sending: Alle Pixeln sind 'ON'
1017
  //char cdata;
1018
  //cdata = 0xA5;
1019
  //SPI_MasterTransmit(cdata);
1020
  //_delay_ms(50);
1021
  
1022
  ClearLCD();
1023
  
1024
  PORTA |= (1<<PA2);
1025
  
1026
  DrawString("HELLO WORD!",0);
1027
  
1028
  DrawString("0123456789      ",1);
1029
  DrawString("ATRUNTIME     ",2);
1030
  DrawString(" -+*=!?              ",3);
1031
  
1032
    
1033
  while(1)
1034
  {
1035
    //DrawString("HELLO WORD!",0);
1036
    //DrawString("0123456789      ",1);
1037
    //DrawString("ATRUNTIME     ",2);
1038
    //DrawString(" -+*=!?              ",3);
1039
    
1040
    PORTF=0x01;
1041
    _delay_ms(500);
1042
    PORTF=0x02;
1043
    _delay_ms(500);
1044
  }
1045
  
1046
  return 0;
1047

1048
}

Ich habe folgende PINs angeschlossen (schematic.
Ich habe bemerkt dass die Pins 26 und 33 sogar einen Potential von etwa 
4,8 V, trotz die auf dem Schaltbild auf Masse bezogen, dann habe ich die 
auf Masse bezogen, jedesmal wenn ich die Pins 26 und 33 auf Masse lege, 
sehe ich auf dem Display alle Pixel schwarz, sonst nix, ich bezweifle 
dass mein /Reset funktioniert !=!

ich freue mich auf eure Meldungen :)
Angehängte Dateien:
#3369890
Lesenswert?

Den Code hast du hoffentlich nicht selbst geschrieben, oder?

Edit: Schonmal die zwei gröbsten Fehler:

- SS ist nicht als Ausgang gesetzt, SPI kann so nicht funktionieren
- A0 wird nicht angesteuert, keine Unterscheidung zwischen Daten und 
Befehlen möglich

Die Font-Routinen löschst du besser ganz schnell bevor das noch jemand 
sieht.

Hast du dir das Datenblatt überhaupt mal angesehen?
OP #3377333
Lesenswert?

Danke für die Info. Nein den Code habe ich selbst komplementiert, sonst 
ss ist schon mit PB0 auf Output gesetzt, du könntest mir gerne die Zeile 
geben wo ich das falsch geschrieben habe, das A0 wird mit PA2 
angesteuert, einmal setze ich ein Low Pegel für die Initialisierung der 
SPI, danach setze ich ein High Pegel für den Aufruf der Funktion 
"DrawString".

was ist mit dem aufgetauchten Potential von 4,8 V, hättest du einen 
Vorschlag für mich, danke :)
(Firma: matzetronics) #3377409
Lesenswert?

Das Datenblatt des DOGM132-5 enthält leider einen Fehler in der 
Beschaltung der Booster Kondensatoren. Erprobt und richtig ist folgende 
Beschaltung für 2,4-3,3V Singlesupply (mit 1µF):
Pin 27 C1 -
Pin 28 C1 +

Pin 29 C2 +
Pin 30 C2 -

Pin 31 C3 +
Pin 32 C3 -
An Pin 21 bis 25 müssen sich Gleichspannungen in Stufen messen lassen. 
Pin 21 hat dann ca. 7,5 Volt bis herunter zu Pin 25 mit 1,25 V. An Pin 
32 liegen ca 8,2 Volt.

Benutzt wird die Initialisierungssequenz für 'Single Supply/Wide Range' 
mit Booster, Regulator und Follower auf 'ein'. Das Reset meiner Displays 
verbinde ich direkt mit dem Reset des AVR.
Gast #3377493
Lesenswert?

#defines sind auch was ganz tolles!

Da braucht man nicht immer in den Schaltplan gucken und die Striche im 
Spinnennetz verfolgen! Gerade für ein Display bietet es sich ja an:

#define DISP_A0 PA2
#define DISP_SS PB0
usw.

Sowas erhöht nicht nur die Lesbarkeit, sondern auch die 
Wiederverwendbarkeit.

Wobei hier nur die Lesbarkeit für alle die deine Fehler suchen gemeint 
ist.

Außerdem kann man eine solch lange Datei anhängen. Damit ersparst du den 
Leuten das stundenlange scrollen!

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