Die LCD Library dient zur Ansteuerung von LCD Anzeigen mit HD44780 Controller
extern void lcd_init(uint8_t dispAttr);
Die Funktion lcd_init() initialisiert das Display. Als Parameter wird eine dieser Optionen übergeben
LCD_DISP_OFF - Display aus LCD_DISP_ON - Display an, Cursor aus LCD_DISP_ON_CURSOR - Display an, Cursor an LCD_DISP_ON_CURSOR_BLINK - Display an, Cursor blinkt
extern void lcd_clrscr(void);
Löscht das Display und setzt den Cursor in die linke obere Ecke.
extern void lcd_home(void);
Setzt den Cursor in die linke obere Ecke.
extern void lcd_gotoxy(uint8_t x, uint8_t y);
Setzt den Cursor an die durch x und y angegebenen Koordinaten.
extern void lcd_putc(char c);
Gibt ein Zeichen an der aktuellen Cursorposition aus.
extern void lcd_cmd(uint8_t cmd);
Die Funktion lcd_cmd() sendet einen Befehl an das Display (RS=0). Vor dem Senden wird das Busy Flag abgefragt.
extern void lcd_data(uint8_t data);
Die Funktion lcd_data() sendet ein Datenbyte an das CGRAM oder an das DDRAM des Displays (RS=1). Vor dem Senden wird das Busy Flag abgefragt.
Um das Display zu konfigurieren müssen einige Defines in der config.h vorgenommen werden.
/*------------------------------------------------------------------------------ * Defines for LCD *----------------------------------------------------------------------------*/ #define LCD_ROWS 2 // Number of Rows #define LCD_COLS 16 // Number of Columns #define LCD_DATA_PORT PORTB // Port Register of the LCD Data Port #define LCD_D4 0 // Port Bit connected to D4 of the LCD #define LCD_CTRL_PORT PORTB // Port Register for the LCD control signals #define LCD_RS 7 // Port Bit of the RS Signal #define LCD_RW 6 // Port Bit of the RW Signal #define LCD_E 5 // Port Bit of the Enable Signal #define LCD_BL 0 // Port Bit to control the Backlight
Dieser Code kann direkt in die config.h übernommen und angepasst werden
#include <config.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <lcd.h> const char HelloFlash[] PROGMEM = "Hello Flash!"; int main(void) { /* initialize display, cursor off */ lcd_init(LCD_DISP_ON); lcd_clr(); /* Clear Display */ lcd_putc("C"); /* Prints the char C on the Display */ write(lcd_putc, "Hello World!"); /* Writes "Hello World!" to the Display (needs utils.h)*/ write_p(lcd_putc, HelloFlash); /* Writes "Hello Flash!" from Program Memory to the Display (needs utils.h and avr/pgmspace.h */ for (;;) ; /* loop forever */ }
Dieser Schaltplan zeigt eine Anschlussmöglichkeit an einem ATmega8-16PU (DIP). Hier wurde PortD verwendet und die Data Ports liegen an PD4 bis PD7.
Getestet mit:
Diskussion
wo finde ich den die config.h ?
Die > avr-gcc LCD Library < muss ich die erst installieren? Oder wie komme ich daran? Bei Synapic nix gefuden.
Danke
Du musst am besten das komplette Paket runterladen. Das findest du hier
http://www.wiki.elektronik-projekt.de/mikrocontroller/avr/avr-gcc-library/start
guten tag
also leider funktioniert das ganze bei mir nicht, gibt ohne ende von fehler meldungen…
hab hab oben das beispiel mal rein kopiert… und config un so alles im ordner drinne. jetzt sagt avr studio er findet lcd_init nicht..