Hi Leute, Ich weiß das Thema kahm schon x mal. Aber ich hab schon die diversesten Themen durchsucht und finde trotzdem keinen Fehler. Versuche gerade folgendes Display zu benutzen. Aber ich hab trotzdem nur schwarze Balken. http://neuhold-elektronik.at/datenblatt/N4105.jpg Bis jetzt rufe ich nur lcd init auf. Erkennt ihr einen Fehler. Auschließen kann ich, dass der Controller nicht läuft. Und Pin mäßig passt auch alles Hier mein Code:
1 | #include "pic.h" |
2 | #include "lcd.h" |
3 | #include "delay.h" |
4 | |
5 | #define LCD_RS RA4
|
6 | #define LCD_RW RA3
|
7 | #define LCD_EN RA2
|
8 | |
9 | #define LCD_DATA PORTC
|
10 | |
11 | #define LCD_STROBE() ((LCD_EN = 1),(LCD_EN=0))
|
12 | |
13 | /* write a byte to the LCD in 4 bit mode */
|
14 | |
15 | void
|
16 | lcd_write(unsigned char c) |
17 | {
|
18 | DelayMs(300); |
19 | LCD_DATA = ( ( c >> 4 ) & 0x0F ); |
20 | LCD_STROBE(); |
21 | DelayMs(300); |
22 | LCD_DATA = ( c & 0x0F ); |
23 | LCD_STROBE(); |
24 | }
|
25 | |
26 | /*
|
27 | * Clear and home the LCD
|
28 | */
|
29 | |
30 | void
|
31 | lcd_clear(void) |
32 | {
|
33 | LCD_RS = 0; |
34 | lcd_write(0x1); |
35 | DelayMs(2); |
36 | }
|
37 | |
38 | /* write a string of chars to the LCD */
|
39 | |
40 | void
|
41 | lcd_puts(const char * s) |
42 | {
|
43 | LCD_RS = 1; // write characters |
44 | while(*s) |
45 | lcd_write(*s++); |
46 | }
|
47 | |
48 | /* write one character to the LCD */
|
49 | |
50 | void
|
51 | lcd_putch(char c) |
52 | {
|
53 | LCD_RS = 1; // write characters |
54 | lcd_write( c ); |
55 | }
|
56 | |
57 | |
58 | /*
|
59 | * Go to the specified position
|
60 | */
|
61 | |
62 | void
|
63 | lcd_goto(unsigned char pos) |
64 | {
|
65 | LCD_RS = 0; |
66 | lcd_write(0x80+pos); |
67 | }
|
68 | |
69 | /* initialise the LCD - put into 4 bit mode */
|
70 | void
|
71 | lcd_init() |
72 | {
|
73 | char init_value; |
74 | |
75 | ADCON1 = 0x06; // Disable analog pins on PORTA |
76 | |
77 | init_value = 0x3; |
78 | TRISA=0; |
79 | TRISC=0; |
80 | LCD_RS = 0; |
81 | LCD_EN = 0; |
82 | LCD_RW = 0; |
83 | |
84 | DelayMs(50); // wait 15mSec after power applied, |
85 | LCD_DATA = init_value; |
86 | LCD_STROBE(); |
87 | DelayMs(10); |
88 | LCD_STROBE(); |
89 | DelayMs(10); |
90 | LCD_STROBE(); |
91 | DelayMs(10); |
92 | LCD_DATA = 2; // Four bit mode |
93 | LCD_STROBE(); |
94 | |
95 | lcd_write(0x28); // Set interface length |
96 | lcd_write(0xF); // Display On, Cursor On, Cursor Blink |
97 | lcd_clear(); // Clear screen |
98 | lcd_write(0x6); // Set entry Mode |
99 | }
|