Danke für eure Antworten.
Ich habe jetzt anstatt der umgeschriebenen Lib die offizielle Lib von
Peter Fleury in Verwendung.
Bin jetzt soweit, dass ich den Curser auch in die zweite Zeile an jede
Position versetzen kann.(DDR Adressen stimmen)
Mein Problem liegt jetzt noch dabei, dass ich den Curser bei mehreren
Resets nicht immer in die gewünschte Position bringe.
Daraus schließe ich, dass bei der Initialisierung noch etwas nicht
stimmt, bin aber noch nicht darauf gekommen, was fehlerhaft ist.
Hier meine Initialisierung:
void lcd_init(uint8_t dispAttr)
{
#if LCD_IO_MODE
/*
* Initialize LCD to 4 bit I/O mode
*/
if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT ==
&LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
&& ( &LCD_RS_PORT == &LCD_DATA0_PORT) && ( &LCD_RW_PORT ==
&LCD_DATA0_PORT) && (&LCD_E_PORT == &LCD_DATA0_PORT)
&& (LCD_DATA0_PIN == 0 ) && (LCD_DATA1_PIN == 1) && (LCD_DATA2_PIN
== 2) && (LCD_DATA3_PIN == 3)
&& (LCD_RS_PIN == 4 ) && (LCD_RW_PIN == 5) && (LCD_E_PIN == 6 ) )
{
/* configure all port bits as output (all LCD lines on same
port) */
DDR(LCD_DATA0_PORT) |= 0x7F;
}
else if ( ( &LCD_DATA0_PORT == &LCD_DATA1_PORT) && ( &LCD_DATA1_PORT
== &LCD_DATA2_PORT ) && ( &LCD_DATA2_PORT == &LCD_DATA3_PORT )
&& (LCD_DATA0_PIN == 0 ) && (LCD_DATA1_PIN == 1) &&
(LCD_DATA2_PIN == 2) && (LCD_DATA3_PIN == 3) )
{
/* configure all port bits as output (all LCD data lines on same
port, but control lines on different ports) */
DDR(LCD_DATA0_PORT) |= 0x0F;
DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
DDR(LCD_E_PORT) |= _BV(LCD_E_PIN);
}
else
{
/* configure all port bits as output (LCD data and control lines
on different ports */
DDR(LCD_RS_PORT) |= _BV(LCD_RS_PIN);
DDR(LCD_RW_PORT) |= _BV(LCD_RW_PIN);
DDR(LCD_E_PORT) |= _BV(LCD_E_PIN);
DDR(LCD_DATA0_PORT) |= _BV(LCD_DATA0_PIN);
DDR(LCD_DATA1_PORT) |= _BV(LCD_DATA1_PIN);
DDR(LCD_DATA2_PORT) |= _BV(LCD_DATA2_PIN);
DDR(LCD_DATA3_PORT) |= _BV(LCD_DATA3_PIN);
}
delay(15000); /* wait 16ms or more after power-on */
/* initial write to lcd is 8bit */
LCD_DATA1_PORT |= _BV(LCD_DATA1_PIN); // _BV(LCD_FUNCTION)>>4;
LCD_DATA0_PORT |= _BV(LCD_DATA0_PIN); // _BV(LCD_FUNCTION_8BIT)>>4;
lcd_e_toggle();
delay(5000); /* delay, busy flag can't be checked here */
/* repeat last command */
lcd_e_toggle();
delay(100); /* delay, busy flag can't be checked here */
/* repeat last command a third time */
lcd_e_toggle();
delay(100); /* delay, busy flag can't be checked here */
/* now configure for 4bit mode */
LCD_DATA0_PORT &= ~_BV(LCD_DATA0_PIN); //
LCD_FUNCTION_4BIT_1LINE>>4
lcd_e_toggle();
delay(100); /* some displays need this additional delay */
/* from now the LCD only accepts 4 bit I/O, we can use lcd_command()
*/
#else
/*
* Initialize LCD to 8 bit memory mapped mode
*/
/* enable external SRAM (memory mapped lcd) and one wait state */
MCUCR = _BV(SRE) | _BV(SRW);
/* reset LCD */
delay(16000); /* wait 16ms after power-on
*/
lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit
interface */
delay(4992); /* wait 5ms
*/
lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit
interface */
delay(64); /* wait 64us
*/
lcd_write(LCD_FUNCTION_8BIT_1LINE,0); /* function set: 8bit
interface */
delay(64); /* wait 64us
*/
#endif
#if KS0073_4LINES_MODE
/* Display with KS0073 controller requires special commands for
enabling 4 line mode */
lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_ON);
lcd_command(KS0073_4LINES_MODE);
lcd_command(KS0073_EXTENDED_FUNCTION_REGISTER_OFF);
#else
lcd_command(LCD_FUNCTION_DEFAULT); /* function set: display
lines */
#endif
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
*/
}/* lcd_init */
Wisst Ihr was man beim Betrieb mit dem KS0066 ändern muss?
Timing?
Danke!