[an error occurred while processing this directive]
|
Вот такая у меня ф-я инициализации(только сильно не пинайте это щас моя первая работа :) )
//некоторые нужные константы :)
#define LCD_ENTRY_INC_ 0x06 /* display shift off, inc cursor move dir */
#define LCD_ENTRY_MODE 2 /* DB2: set entry mode */
/* function set: set interface data length and number of display lines */
#define LCD_FUNCTION_4BIT_1LINE 0x20 /* 4-bit interface, single line, 5x7 dots */
#define LCD_FUNCTION_4BIT_2LINES 0x28 /* 4-bit interface, dual line, 5x7 dots */
#define LCD_FUNCTION_8BIT_1LINE 0x30 /* 8-bit interface, single line, 5x7 dots */
#define LCD_FUNCTION_8BIT_2LINES 0x38 /* 8-bit interface, dual line, 5x7 dots */
/* display on/off, cursor on/off, blinking char at cursor position */
#define LCD_DISP_OFF 0x08 /* display off */
#define LCD_DISP_ON 0x0C /* display on, cursor off */
#define LCD_DISP_ON_CURSOR_BLINK 0x0F /* display on, cursor on, blink char */
#define LCD_FUNCTION_DEFAULT LCD_FUNCTION_4BIT_2LINES outp( 0xFF, LCD_DDR_PORT ); /* all port bits as output */ delay(16000*2); /* wait 16ms or more after power-on */ /* initial write to lcd is 8bit */ outp(LCD_FUNCTION_8BIT_2LINES>>4,LCD_DATA_PORT); outp(LCD_FUNCTION_8BIT_2LINES>>4,LCD_DATA_PORT); outp(LCD_FUNCTION_4BIT_2LINES>>4,LCD_DATA_PORT); /* set IO mode to 4bit */ /* from now the lcd only accepts 4 bit I/O, we can use lcd_command() */ }/* lcd_init */ static void inline lcd_write(uint8_t data,uint8_t rs) /* output high nibble first */ /* output low nibble */ /* output high nibble first */ /* output low nibble */ } cbi(LCD_RS_PORT,LCD_MY_RS); а вот так её вызываю lcd_init(LCD_DISP_ON_CURSOR_BLINK);
E-mail:
info@telesys.ru
#define LCD_MODE_DEFAULT ((1<
void lcd_init(uint8_t dispAttr)
/* initialize display and select type of cursor */
/* dispAttr: LCD_DISP_OFF, LCD_DISP_ON, LCD_DISP_ON_CURSOR, LCD_DISP_CURSOR_BLINK */
{
/*------ Initialize lcd to 4 bit i/o mode -------*/
outp( 0xFF, DDRC); /* LCD_E_PORT = LCD_RS_PORT so one line is enoughf :-) */
outp(LCD_FUNCTION_8BIT_2LINES>>4,LCD_DATA_PORT);
lcd_e_toggle();
delay(4992*2); /* delay, busy flag can't be checked here */
lcd_e_toggle();
delay(64*2); /* delay, busy flag can't be checked here */
lcd_e_toggle();
delay(64*2); /* delay, busy flag can't be checked here */
lcd_e_toggle();
lcd_command(LCD_FUNCTION_DEFAULT); /* function set: display lines */
lcd_command(LCD_DISP_OFF); /* display off */
lcd_clrscr(); /* display clear */
lcd_command(LCD_MODE_DEFAULT); /* set entry mode */
lcd_command(dispAttr); /* display/cursor control */
{
/* configure data pins as output */
outp(0xFF, LCD_DDR_PORT);
outp(0xFF, DDRC);
if (rs) { /* write data (RS=1, RW=0) */
sbi(LCD_RS_PORT,LCD_MY_RS);
outp( ((data)&0xF0)/*|(1<
lcd_e_toggle();
sbi(LCD_RS_PORT,LCD_MY_RS);
outp( ((data<<4)&0xF0)/*|(1<
} else { /* write instruction (RS=0, RW=0) */
cbi(LCD_RS_PORT,LCD_MY_RS);
outp( (data)&0xF0, LCD_DATA_PORT );
lcd_e_toggle();
cbi(LCD_RS_PORT,LCD_MY_RS);
outp( (data<<4)&0xF0, LCD_DATA_PORT );
lcd_e_toggle();
cbi(LCD_E_PORT,LCD_MY_E);
/* all data pins high (inactive) */
outp(0xF0, LCD_DATA_PORT);
delay(100);
}
void lcd_command(uint8_t cmd)
/* send commando
{
delay(80);
lcd_write(cmd,0);
}
вызвваю я её 3 раз где-то после 3-5 сек после старта проги
Ответы