컴파일러
http://easynews.dl.sourceforge.net/sourceforge/winavr/WinAVR-20060421-install.exe
회로도 http://dubel.org/atmel/devatmel.sch
회로기판 http://dubel.org/atmel/devatmel.brd
/** * Hitachi HD44780 interface code. Provides initialization and functions * to write data and commands to a display. The code is written for a * 20x4 display, but the line wrap constants can be changed for other displays. * The display should be connected as follows to an available port on the atmel: * PORTx [7:0] = E1 E0 RW RS D7 D6 D5 D4 (E1 is not normally used) * Define your LCD port in lcd.h. Make sure that port is set as output, * DDRx = 0xFF; * Call LCD_init() before sending commands or data. * us50_sleep() is defined as a 50uSec delay. Adjust the passed parameter * accordingly for your available delay routine. * Note: RW on the display can be tied to ground to save a pin. * The source compiles on avr-gcc */ #include "lcd.h" #include "bios.h" int pos = 0; void LCD_command(int db) { LCD = (db >> 4) | E0; us50_sleep(1); LCD = db >> 4; us50_sleep(5); LCD = (db & 0x0F) | E0; us50_sleep(1); LCD = db & 0x0F; us50_sleep(100); } /** * Sends the command to clear the display, and resets the position * variable (used to track line wrap). */ void LCD_clear() { //Clear Home LCD_command(0x01); pos = 0; } /** * Initialize a Hitachi 4x20 4 bit mode display * E1 E0 RW RS D7 D6 D5 D4 */ void LCD_init() { us50_sleep(300); //15 //initialize to 4 bit mode: LCD_command(0x33); us50_sleep(100); LCD_command(0x32); //2 lines 5x8 font LCD_command(0x28); //Display, no Curser, no Blink LCD_command(0x0C); // F curser and blink, E just curser LCD_clear(); } /** * Allows you to print a string of data. While this method works fine, it does * not allow for special formatting such as printf. It requires null terminated * strings. For special formatting, call fdevopen(LCD_data, NULL, 0); after * initializing the display, and use printf instead to write data. */ void LCD_string(char db []) { for (; *db!='\0';db++) LCD_data(*db); } /** * Moves the curser to the passed row and column, starting at (0,0) * written for a 4x20 display. */ void LCD_moveTo(int row, int col) { pos = (row*20) + col; if (pos<20) LCD_command(0x80 | pos); if (pos>=20 && pos<40) LCD_command(0x80 | (pos%20 + 0x40)); if (pos>=40 && pos<60) LCD_command(0x80 | (pos%40 + 0x14)); if (pos>60) LCD_command(0x80 | (pos%60 + 0x54)); } /** * This takes care of line wrap for a 20x4 display. The line wrap positions * could be defined in constants for other popular displays, such as 16x2. */ void LCD_data(char db) { // proper line wrap: if (pos==20) LCD_command(0xC0); if (pos==40) LCD_command(0x94); if (pos==60) LCD_command(0xD4); //first nibble & strobe LCD = (db >> 4) | E0 | RS; us50_sleep(1); LCD = (db >> 4) | RS; us50_sleep(1); //second nibble & strobe LCD = (db & 0x0F) | E0 | RS; us50_sleep(1); LCD = (db & 0x0F) | RS; us50_sleep(1); if (++pos==80) pos = 0; }
헤더파일
#define E0 0x40 #define RS 0x10 #define LCD PORTA extern void LCD_command(int db); extern void LCD_clear(void); extern void LCD_string(char db []); extern void LCD_init(void); extern void LCD_moveTo(int row, int col); extern void LCD_data(char db);
http://dubel.org/atmel/hd44780.pdf
캐드 프로그램 이글(독수리) 다운로드
ftp://ftp.cadsoft.de/eagle/program/4.16r1
ftp://ftp.cadsoft.de/eagle/program/4.16r1/eagle-win-eng-4.16r1.zip (영어 윈도우즈환경용)
ftp://ftp.cadsoft.de/eagle/program/4.16r1/eagle-win-eng-4.16r1.exe
반응형
'마이크로컨트롤러(Microcontroller)' 카테고리의 다른 글
16비트 마이컴 (0) | 2006.08.06 |
---|---|
R8C/15,17 시작키트(16비트 원칩 초소형마이컴) (0) | 2006.08.06 |
R8C/Tiny (0) | 2006.07.31 |
eZ430-F2013 (0) | 2006.04.28 |
ATMEGA103 마이컴IC (0) | 2006.03.03 |