Hallo Leute! Weil immer Leute danach fragen, hier eine Quelle in C. Das legt ausserdem den printf() auf das Display um: stdout->_func_out = my_pput; // legt die stdout auf das Display um Gruss, Holger [Anm. der Redaktion:] Subject geändert ;-) //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Diese Funktion beinhaltet eine einfache 8-Bit LCD-Routine // Und lenkt printf auf das Display um //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Belegung Port | LCD // P8.6 | EN (6) // P8.7 | RS (4) // P0.7 | DB7 (14) // P0.6 | DB6 (13) // P0.5 | DB5 (12) // P0.4 | DB4 (11) // P0.3 | DB3 (10) // P0.2 | DB2 (9) // P0.1 | DB1 (8) // P0.0 | DB0 (7) // GND | R/W (5) // GND | VSS (1) // +5V | VDD (2) // 220R to GND | contrast (3) //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // 2.2002 Holger Buss // http://www.mikrocontroller.com //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #include <stdio.h> #define DispRS p8_7 // Achtung: Bitte entsprechend die Ports anpassen #define DispEN p8_6 // Achtung: Bitte entsprechend die Ports anpassen #define DispPort p0 // Achtung: Bitte entsprechend die Ports anpassen #include "sfr62.h" // entsprechend dem Prozessor anpassen ( hier: M16C62) unsigned char Text[]="Hello world \0"; void _long_delay(void) { long t = 1000; while (t--); } void _lcd_write_data(unsigned char data) { DispRS = 0; DispPort = data; DispEN = 1; DispEN = 1; DispEN = 0; } void lcd_write_byte(unsigned char data) { DispRS = 1; DispPort = data; DispEN = 1; DispEN = 1; DispEN = 0; } int my_pput(int zeichen) { lcd_write_byte((unsigned char) zeichen); } // initialize the LCD controller void lcd_init(void) { _long_delay(); _lcd_write_data(0x38); // 4-bit:0x28 8-Bit:0x38 _long_delay(); _lcd_write_data(0x38); _long_delay(); _lcd_write_data(0x02); _long_delay(); _lcd_write_data(0x06); _long_delay(); _lcd_write_data(0x0c); _long_delay(); _lcd_write_data(0x10); _long_delay(); _lcd_write_data(1); // clear LCD _long_delay(); } void WriteLCD(unsigned char *this_text) { unsigned char i = 0; while(this_text[i] != 0) { lcd_write_byte(this_text[i++]); } } void far main() { unsigned int i = 1234; lcd_init(); stdout->_func_out = my_pput; // legt die stdout auf das Display um _lcd_write_data(0xc0); // cursor Line 2 WriteLCD(Text); printf("Moin %u",i); while(1) // das war`s { } }
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.