Gast
#287726
AVR-Tutorial - 4. LCD asm habe ich mal in fastavr-basic umgesetzt. es ist erstaunlich wie leicht/einfach es damit geht. und funktioniert zu 100% und man kann die lcd-befehle beliebig erweitern und verfolgen im ablauf. mfg pebisoft $Device= m16 $Stack = 32 $Clock = 8 $Baud = 19200 Dim temp1 As Byte Dim temp2 As Byte Dim daten As Byte Dim text_lang As Byte Dim text_anfang As Byte Dim text_lcd As String *16 Declare Sub lcd_char() Declare Sub lcd_string() Declare Sub lcd_command() Declare Sub lcd_init() Declare Sub lcd_clear() Declare Sub lcd_enable() DDRC=&b11111111 lcd_init() lcd_clear() text_lcd="es geht doch !" lcd_string() End Sub lcd_string() text_lang=Len(text_lcd) For text_anfang=1 To text_lang daten=Asc(text_lcd, text_anfang) lcd_char() Next End Sub Sub lcd_char() temp1=daten temp2=daten Swap(temp1) temp1=temp1 And &b00001111 temp1=temp1 Or &b00100000 PORTC=temp1 lcd_enable() temp2=temp2 And &b00001111 temp2=temp2 Or &b00100000 PORTC=temp2 lcd_enable() WaitUs 5 End Sub Sub lcd_command() temp1=daten temp2=daten Swap(temp1) temp1= temp1 And &b00001111 PORTC=temp1 lcd_enable() temp2=temp2 And &b00001111 PORTC=temp2 lcd_enable() WaitUs 5 End Sub Sub lcd_init() WaitMs 250 PORTC=&b00000011 lcd_enable() WaitMs 5 lcd_enable() WaitMs 5 lcd_enable() WaitMs 5 PORTC=&b00000010 lcd_Enable() WaitMs 5 daten=&b00011000 lcd_command() daten=&b00001100 lcd_command() daten=&b00000100 lcd_command() End Sub Sub lcd_clear() daten=&b00000001 lcd_command() WaitMs 5 End Sub Sub lcd_enable() PORTC.4=1 Nop 3 PORTC.4=0 End Sub