Wie kann ich die LCD Library von Peter Fleury fachgerecht in mein WinAVR System einbinden. Ich möchte nicht immer die "lcd.c" Datei mitschleppen, wenn das irgendwie ginge. Wie kann ich daraus ein "Objekt-Code"-Datei machen, die dann wenn nötig eingebunden wird. Wohin gehört dann so eine "lcd.o" Datei ? Oder bin ich da ganz auf dem falschen Pfad? Gruss Toni
Naja, Du compilierst sie und legst sie als lcd.o mit bei, oder Du packst sie in ein Archiv (Endung .a) und gibst dies mit an. Du solltest aber darauf achten, daß das .o/.a für den gleichen MCU-Typ compiliert worden sind. Für eine einzige Datei lohnt sich wahrscheinlich der Streß mit dem Handling überhaupt nicht.
Vielen Dank für die Antwort. Ich verstehe wohl richtig, dass es nicht gut möglich ist, diese Library in das WinAVR System so einzubinden, dass sich als Resultat die Benutzung dieser LCD-Library-Funktionen nicht von der Verwendung der anderen "avr-libc Modulen" unterscheidet. Schon wieder was gelernt ! Toni
Das Include lcd.h muss für das jeweilige Projekt angepasst werden, (Typ von LCD, Port/Pin Belegung). Mit diesen Angaben aus dem Include-File wird dann vom Compiler zur Compile-Zeit ein optimiertes LCD-Module (lcd.o) erzeugt.
Hallo, @ Peter Fleury: ich möchte ein LCD im 4bit-Modus mit den Datenleitungen an den high-nibble des LCD-Ports (Pin 4 ... 7) anschließen und Deine LCD-Library nutzen. Der Grund: Die Avr-Ctrl-Platine von www.microcontroller.com nutzt diese Pins als Daten-Bits. siehe: http://mikrocontroller.cco-ev.de/images/avr_schaltplan.gif Könnte folgende Änderung an Deiner LCD.C funktionieren? ... #if LCD_IO_MODE static void inline lcd_write(uint8_t data,uint8_t rs) { /* configure data pins as output */ outp(0xFF, DDR(LCD_DATA_PORT) ); if (rs) { /* write data (RS=1, RW=0) */ /* output high nibble first */ outp(((data&0xF0)|(1<<LCD_RS_PIN), LCD_DATA_PORT ); lcd_e_toggle(); /*(data>>4)&0x0F)*/ /* output low nibble */ outp(((data<<4)&0xF0)|(1<<LCD_RS_PIN), LCD_DATA_PORT ); lcd_e_toggle(); } else { /* write instruction (RS=0, RW=0) */ /* output high nibble first */ outp((data&0xF0), LCD_DATA_PORT ); lcd_e_toggle(); /* output low nibble */ outp((data<<4)&0xF0, LCD_DATA_PORT ); lcd_e_toggle(); } /* all data pins high (inactive) */ outp(0xF0, LCD_DATA_PORT); } #else #define lcd_write(d,rs) if (rs) *(volatile uint8_t*)(LCD_IO_DATA) = d; else *(volatile uint8_t*)(LCD_IO_FUNCTION) = d; /* rs==0 -> write instruction to LCD_IO_FUNCTION */ /* rs==1 -> write data to LCD_IO_DATA */ #endif #if LCD_IO_MODE static uint8_t lcd_read(uint8_t rs) { register uint8_t dataH, dataL; if (rs) sbi(LCD_RS_PORT, LCD_RS_PIN); /* RS=1: read data */ else cbi(LCD_RS_PORT, LCD_RS_PIN); /* RS=0: read busy flag */ sbi(LCD_RW_PORT, LCD_RW_PIN); /* RW=1 read mode */ /* configure data pins as input */ outp(0x0F, DDR(LCD_DATA_PORT)); lcd_e_high(); lcd_e_delay(); dataH = inp(PIN(LCD_DATA_PORT)); /* read high nibble first */ lcd_e_low(); lcd_e_delay(); /* Enable 500ns low */ lcd_e_high(); lcd_e_delay(); dataL = inp(PIN(LCD_DATA_PORT)); /* read low nibble */ lcd_e_low(); return ( (dataH&0xF0) | (dataL>>4) ); } #else #define lcd_read(rs) (rs) ? *(volatile uint8_t*)(LCD_IO_DATA+LCD_IO_READ) : *(volatile uint8_t*)(LCD_IO_FUNCTION+LCD_IO_READ) /* rs==0 -> read instruction from LCD_IO_FUNCTION */ /* rs==1 -> read data from LCD_IO_DATA */ #endif ... Bei mir funktioniert es nicht. Ich denke, es könnte aber auch ein Problem mit dem Makefile dahinterstecken, weil das compilieren nur mit der folgenden Fehlermeldungen abbricht: avr-gcc -c -g -Os -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -mmcu=at90s8535 -Wa,-ahlmsnd=lcdhn.lst -I. lcdhn.c -o lcdhn.o lcdhn.c:351:1: unterminated argument list invoking macro "outp" lcdhn.c: In function `lcd_write': lcdhn.c:100: error: `outp' undeclared (first use in this function) lcdhn.c:100: error: (Each undeclared identifier is reported only once lcdhn.c:100: error: for each function it appears in.) lcdhn.c:100: error: parse error at end of input lcdhn.c:75: warning: `delay' defined but not used lcdhn.c:83: warning: `toggle_e' defined but not used make.exe: *** [lcdhn.o] Error 1 Man merkt es sofort, ich habe wenig Erfahrung mit C, aber ich verstehe trotzdem nicht, warum outp nicht gefunden wird. Es wird doch eingebunden: #include <avr/io.h> #include "sfr_defs.h" /* #include "lcd.h" */ #include "lcdhn.h" /* lcdhn.h ist die von mir modifizierte Version von lcd.h , hn steht für highnibble. lcdhn.c analog. */ Ich bin für jede Hilfe dankbar. Matthias
Bitte verwende meine neueste LCD library Version von meiner Homepage (http:/jump.to/fleury), dort lassen sich die einzelnen LCD-Pins einzelnen Port Pins zuordnen.
Ich habe auch versucht, diese Lib einzubinden. Leider zeigt mein Display 2x16 nur die dunkle Kästen an. OK, Kontrast etwas hoch, ist aber die AVR-CTRL 1.0 Schaltung. Wie müßte da die lcd.h aussehen. Hier meine #define LCD_PORT PORTC /**< port for the LCD lines */ #define LCD_DATA0_PORT LCD_PORT /**< port for 4bit data bit 0 */ #define LCD_DATA1_PORT LCD_PORT /**< port for 4bit data bit 1 */ #define LCD_DATA2_PORT LCD_PORT /**< port for 4bit data bit 2 */ #define LCD_DATA3_PORT LCD_PORT /**< port for 4bit data bit 3 */ #define LCD_DATA0_PIN 4 /**< pin for 4bit data bit 0 */ #define LCD_DATA1_PIN 5 /**< pin for 4bit data bit 1 */ #define LCD_DATA2_PIN 6 /**< pin for 4bit data bit 2 */ #define LCD_DATA3_PIN 7 /**< pin for 4bit data bit 3 */ #define LCD_RS_PORT LCD_PORT /**< port for RS line */ #define LCD_RS_PIN 0 /**< pin for RS line */ #define LCD_RW_PORT LCD_PORT /**< port for RW line */ #define LCD_RW_PIN 1 /**< pin for RW line */ #define LCD_E_PORT LCD_PORT /**< port for Enable line */ #define LCD_E_PIN 2 /**< pin for Enable line */ Als main Funktion läuft das hier: int main(void) { lcd_init(LCD_DISP_ON_CURSOR); lcd_clrscr(); for (;;) { lcd_puts("Hallo Welt"); } }
@0190: Der LCD-Port ist bei Dir korrekt: PORTC die PIN-Nummern auch. Bei mir funktionierte das Ganze auf Anhieb mit der test_lcd.c, die Peter Fleury mitliefert. Für die Tastenfunktion zum Weiterschalten muß man diese nur ein klein wenig verändern. Bei #define XTAL ist Dein Systemtakt eingetragen? Make liefert keine Fehler? Probiere doch mal das hier: #include <stdlib.h> #include <avr/io.h> #include "lcd.h" int main(void) { lcd_init(LCD_DISP_ON_CURSOR); lcd_clrscr(); lcd_puts("Hallo Welt"); for (;;) {} } Funktioniert bei mir einwandfrei. Gruß Matthias
Ich denke mein LCD hat eins weg, heute sollte ein neues kommen. Ja der Takt ist auf 8Mhz eingestellt. Werd es dann nochmal probieren. Danke
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.