Juhuuuuuuuuuuuu! Es klappt! fast zumindest... :-D
[code]
static void lcd_e_toggle(void);
static void lcd_write(uint8_t data,uint8_t rs)
{
if (rs) /* write data (RS=1, RW=0) */
LCD_RS_PORT |= (1<<LCD_RS_PIN);
else /* write instruction (RS=0, RW=0) */
LCD_RS_PORT &= ~(1<<LCD_RS_PIN);
/* output high nibble first */
PORTA = (data & 0xF0);
lcd_e_toggle();
/* output low nibble */
PORTA = ( (data & 0x0F) << 4);
lcd_e_toggle();
/* all data pins high (inactive) */
PORTA = 0xff;
}
////////////////////////////////////////////////////////////////////////
//
void lcd_gotoxy(uint8_t x, uint8_t y)
{
if ( y==0 )
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE1+x);
else if ( y==1)
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE2+x);
else if ( y==2)
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE3+x);
else /* y==3 */
lcd_command((1<<LCD_DDRAM)+LCD_START_LINE4+x);
}
////////////////////////////////////////////////////////////////////////
//
/***********************************************************************
**
Input: dispAttr LCD_DISP_OFF display off
LCD_DISP_ON display on, cursor off
LCD_DISP_ON_CURSOR display on, cursor on
LCD_DISP_CURSOR_BLINK display on, cursor on
flashing
************************************************************************
*/
void lcd_init(uint8_t dispAttr)
{
/* configure all port bits as output (LCD data and control lines on
different ports */
DDRC |= (1<<LCD_RS_PIN);
DDRC |= (1<<LCD_E_PIN);
//Licht
DDRC |= (1<<3);
DDRA |= 0xff;
_delay_ms(60); /* wait a minimum of 60ms or more after
power-on */
/* configure for 4bit mode */
LCD_DATA1_PORT |= (1<<LCD_DATA1_PIN);
lcd_e_toggle(); /* send this command 2 times */
lcd_e_toggle();
LCD_DATA1_PORT &= ~(1<<LCD_DATA1_PIN);
/* set number of lines */
lcd_e_toggle();
_delay_us(60);
/* from now the LCD only accepts 4 bit I/O, we can use lcd_command()
*/
lcd_command(LCD_DISP_OFF); /* display off
*/
_delay_ms(5);
lcd_clrscr(); /* display clear
*/
_delay_ms(10);
lcd_command(LCD_MODE_DEFAULT); /* set entry mode
*/
lcd_command(dispAttr); /* display/cursor control
*/
// Licht an
backlight_on();
}
////////////////////////////////////////////////////////////////////////
//
void lcd_clrscr(void)
{
lcd_command(1<<LCD_CLR);
}
////////////////////////////////////////////////////////////////////////
//
void lcd_home(void)
{
lcd_command(1<<LCD_HOME);
}
////////////////////////////////////////////////////////////////////////
//
static void lcd_e_toggle(void)
{
LCD_E_PORT |= (1<<LCD_E_PIN);
_asm_ __volatile__( "rjmp 1f\n 1:" );
LCD_E_PORT &= ~(1<<LCD_E_PIN);
}
////////////////////////////////////////////////////////////////////////
//
void lcd_putc(char c)
{
_delay_ms(100); // read busy-flag and address counter
lcd_write(c, 1);
}
////////////////////////////////////////////////////////////////////////
//
void lcd_puts(const char *s)
/* print string on lcd (no auto linefeed) */
{
register char c;
while ( (c = *s++) ) {
lcd_putc(c);
}
}
////////////////////////////////////////////////////////////////////////
//
void lcd_command(uint8_t cmd)
{
_delay_ms(100);
lcd_write(cmd,0);
}
////////////////////////////////////////////////////////////////////////
//
void lcd_data(uint8_t data)
{
_delay_ms(100);
lcd_write(data,1);
}
[\code]
Ein Problem bleibt. Ich bekomme nur 2 (erste und dritte) Zeile
angezeigt. Ich weiß mir nicht zu helfen, da puts() in einer
Endlosschleife chars ausgibt und Zeilen umbricht (RAM durchschreibt)
ohne dabei in Zeile 2 und 4 vorbeizuschaun.
Komisch aber ihr könnt euch nicht vorstellen wie glücklich ich jetz
bin!!