Also hier wie gefordert mein Code für das 64128, den ich zu testzwecken zusammengepfriemelt hab. Es ging bei dem Projekt um ein einfaches "Digitaloszi" mit dem ATMega mit internem ADC und GLCD. Hat also dementsprechend nur den Zweck Linien auf dem Display zu zeichnen. Der Vorteil meiner Ansteuerung war halt, das man beliebige Pins für die Ansteuerung nutzen kann, dafür ists halt etwas langsamer als die Bascominterne Routine.

Code:
'----------------------------------------------------------
' Programm initialisieren
'----------------------------------------------------------
'$dbg
'
' ACHTUNG JTAG per Fuse abschalten !!!!
'

$regfile = "m16def.dat"
$crystal = 8000000

$baud = 19200

Declare Sub Glcd_wdata(byval Outbyte As Byte)
Declare Function Glcd_rdata(byval Outbyte As Byte)as Byte
Declare Sub Glcd_busycheck
Declare Sub Glcd_pixpos(byval Pixpos_x As Byte , Byval Pixpos_y As Byte , Byval Modus As Byte)
Declare Sub Glcd_framepos(byval Pixpos_x As Byte , Byval Pixpos_y As Byte , Byval Framedata As Byte)
Declare Sub Glcd_line(byval Sx As Byte , Byval Sy As Byte , Byval Ex As Byte , Byval Ey As Byte)


Glcd_db0 Alias Portd.7
Glcd_pindb0 Alias Pind.7
Glcd_db1 Alias Portd.6
Glcd_pindb1 Alias Pind.6
Glcd_db2 Alias Porta.2
Glcd_pindb2 Alias Pina.2
Glcd_db3 Alias Porta.3
Glcd_pindb3 Alias Pina.3
Glcd_db4 Alias Porta.4
Glcd_pindb4 Alias Pina.4
Glcd_db5 Alias Porta.5
Glcd_pindb5 Alias Pina.5
Glcd_db6 Alias Porta.6
Glcd_pindb6 Alias Pina.6
Glcd_db7 Alias Porta.7
Glcd_pindb7 Alias Pina.7
Glcd_cs0 Alias Portb.0
Glcd_cs1 Alias Portb.1
Glcd_e Alias Portb.2
Glcd_rs Alias Portb.4
Glcd_res Alias Portb.3
Glcd_rw Alias Portd.3

Config Glcd_db0 = Output
Config Glcd_db1 = Output
Config Glcd_db2 = Output
Config Glcd_db3 = Output
Config Glcd_db4 = Output
Config Glcd_db5 = Output
Config Glcd_db6 = Output
Config Glcd_db7 = Output
Config Glcd_cs0 = Output
Config Glcd_cs1 = Output
Config Glcd_e = Output
Config Glcd_rs = Output
Config Glcd_res = Output
Config Glcd_rw = Output

Config Porta.0 = Input
Config Adc = Single , Prescaler = 64 , Reference = Off
Start Adc


Dim A As Byte
Dim B As Word

Dim Senstemp(120) As Word
Dim Tempword As Word                                        ' variablen deklarieren
Dim I As Byte
Dim X As Byte
Dim Tmpsingle As Single
Dim Temp As Word
Dim Tempint As Integer
Dim Tempstr As String * 16
Dim Sx As Byte , Sy As Byte , Ex As Byte , Ey As Byte , Xsingle As Single , Ysingle As Single
Dim Framedata As Byte
Dim Pixpos_x As Byte
Dim Pixpos_y As Byte
Dim Tmp As Byte
Dim Outbyte As Byte
Dim Modus As Byte
Dim Y_alt As Byte
Dim X_alt As Byte
Dim Y_neu As Byte
Dim X_neu As Byte
Dim Y_alt2 As Byte
Dim X_alt2 As Byte
Dim Y_neu2 As Byte
Dim X_neu2 As Byte
Dim Pwm1ab As Word
X_alt = 1
Y_alt = 1
X_neu = 1
Y_neu = 1

Config Pinc.2 = Output
Config Pinc.3 = Input
Config Portc.5 = Output
Config Portc.6 = Output
Config Portc.7 = Output

Enable Interrupts

Gosub Glcd_init
Gosub Glcd_cls

Call Glcd_line(1 , 1 , 126 , 62)
Call Glcd_line(1 , 62 , 126 , 1 )
Call Glcd_line(20 , 20 , 106 , 42)
Call Glcd_line(20 , 42 , 106 , 20)
Wait 1
Gosub Glcd_cls

Do

Loop
End

' --------------------------------------------------------------------

Sub Glcd_pixpos(byval Pixpos_x As Byte , Byval Pixpos_y As Byte , Modus As Byte)
     Local Templocal As Integer
     If Pixpos_y < 62 Then
     If Pixpos_x < 126 Then
     Glcd_rs = 1
     Glcd_rw = 0
     If Modus = 1 Then
         Tmp = Pixpos_y
         Shift Tmp , Right , 3                              ' pixel im Frame setzen
         Shift Tmp , Left , 3
         Pixpos_y = Pixpos_y - Tmp
         Tmp = 0
         Tmp.pixpos_y = 1
         Tmp = Framedata Or Tmp
         Call Glcd_wdata(tmp)                               ' pixel schreiben
      Else
         Call Glcd_wdata(0)                                 ' frame löschen
      End If
      Glcd_rs = 0
      End If
      End If
End Sub

'------------------------------------------------------------------

Sub Glcd_framepos(byval Pixpos_x As Byte , Byval Pixpos_y As Byte , Byref Framedata As Byte)
     Local Tempbyte As Byte
     If Pixpos_y < 62 Then
     If Pixpos_x < 126 Then
     Glcd_cs0 = 0
     Glcd_cs1 = 0
     Glcd_rs = 0
     Glcd_rw = 0
     If Pixpos_x > 61 Then                                  ' chip auswählen
        Glcd_cs1 = 1
        Pixpos_x = Pixpos_x And &B00111111
     Else
        Glcd_cs0 = 1
        Pixpos_x = Pixpos_x And &B00111111
        'Decr Pixpos_x
        'Decr Pixpos_x
        'Decr Pixpos_x
     End If

     Tmp = Pixpos_x
     Tmp = Tmp And &B00111111
     Tmp = Tmp Or &B01000000
     Call Glcd_wdata(tmp)                                   ' x-Adresse setzen

     Shift Pixpos_y , Right , 3
     Tmp = Pixpos_y And &B00011111                          '/ 8
     Tmp = Tmp Or &B10111000                                ' frame setzen für Abfrage
     Call Glcd_wdata(tmp)
     Glcd_rs = 1
     Glcd_rw = 1
         Framedata = Glcd_rdata(0)                          ' Frame auslesen
     Glcd_rw = 0
     Glcd_rs = 0
     Call Glcd_wdata(tmp)
     End If
     End If
End Sub
End

' --------------------------------------------------------------------

Sub Glcd_wdata(byval Outbyte As Byte)

    nop
    nop
    Glcd_e = 0
    Glcd_db0 = Outbyte.0
    Glcd_db1 = Outbyte.1
    Glcd_db2 = Outbyte.2
    Glcd_db3 = Outbyte.3
    Glcd_db4 = Outbyte.4
    Glcd_db5 = Outbyte.5
    Glcd_db6 = Outbyte.6
    Glcd_db7 = Outbyte.7
    nop
    Glcd_e = 1
    nop
    Glcd_e = 0
End Sub
End

' --------------------------------------------------------------------

Function Glcd_rdata(byval Outbyte As Byte)as Byte
    Config Glcd_db0 = Input
    Config Glcd_db1 = Input
    Config Glcd_db2 = Input
    Config Glcd_db3 = Input
    Config Glcd_db4 = Input
    Config Glcd_db5 = Input
    Config Glcd_db6 = Input
    Config Glcd_db7 = Input
    Glcd_e = 0
    nop
    Glcd_e = 1
    nop
    Glcd_e = 0
    nop
    Glcd_e = 1
    nop

    Outbyte.0 = Glcd_pindb0
    Outbyte.1 = Glcd_pindb1
    Outbyte.2 = Glcd_pindb2
    Outbyte.3 = Glcd_pindb3
    Outbyte.4 = Glcd_pindb4
    Outbyte.5 = Glcd_pindb5
    Outbyte.6 = Glcd_pindb6
    Outbyte.7 = Glcd_pindb7
    Glcd_rdata = Outbyte
    Framedata = Outbyte
    nop
    Config Glcd_db0 = Output
    Config Glcd_db1 = Output
    Config Glcd_db2 = Output
    Config Glcd_db3 = Output
    Config Glcd_db4 = Output
    Config Glcd_db5 = Output
    Config Glcd_db6 = Output
    Config Glcd_db7 = Output
    nop
    Glcd_e = 0
    nop
    nop
End Function
End

' --------------------------------------------------------------------

Glcd_init:
   Glcd_res = 1
   Waitms 400
   Glcd_res = 0
   Waitms 400
   Glcd_res = 1
   Waitms 400
   Glcd_rs = 0
   Glcd_rw = 0
   nop
   nop
   nop
   Glcd_cs0 = 1                                             ' Instruktionen
   Glcd_cs1 = 0
   Call Glcd_wdata(&B00111111 )
   nop
   nop
   nop
   Call Glcd_wdata(&B11000000 )
   nop
   nop
   nop
   Call Glcd_wdata(&B10111000 )
   nop
   nop
   nop
   Call Glcd_wdata(&B01000000 )
   Glcd_rs = 0
   Glcd_rw = 0
   nop
   nop
   nop
   Glcd_cs0 = 0                                             ' Instruktionen
   Glcd_cs1 = 1
   Call Glcd_wdata(&B00111111)
   nop
   nop
   nop
   Call Glcd_wdata(&B11000000 )
   nop
   nop
   nop
   Call Glcd_wdata(&B10111000 )
   nop
   nop
   nop
   Call Glcd_wdata(&B01000000 )
Return
End

Glcd_cls:
   Glcd_rs = 1
   Glcd_rw = 0
   X = 0
   For A = 1 To 128                                         ' Bildschirm löschen
      For I = 1 To 60 Step 8
         Call Glcd_framepos(a , I , X)
         Call Glcd_pixpos(a , I , X)
      Next I
   Next A
Return
End


Glcd_mirror:
   Glcd_rs = 1
   Glcd_rw = 0
   For X = 1 To 63
      For A = 1 To 128
         Call Glcd_framepos(a , X , 1)
         Call Glcd_pixpos(a , X , 1)
      Next A
   Next X
Return
End

Sub Glcd_line(byval Sx As Byte , Byval Sy As Byte , Byval Ex As Byte , Byval Ey As Byte)
   Local Dx As Integer
   Local Dy As Integer
   Local Yb As Byte
   Local Xb As Byte
   Local Xcount As Byte
   Xb = 0
   Yb = 0
   Dx = Sx - Ex
   Dy = Sy - Ey
   Ysingle = Dy / Dx
   For Xcount = Ex To Sx Step -1
      Yb = Ysingle * Xb
      Yb = Yb + Sy
      Call Glcd_framepos(xcount , Yb , 1)
      Call Glcd_pixpos(xcount , Yb , 1)
      Incr Xb
      Yb = Ysingle * Xb
      Yb = Yb + Sy
      Call Glcd_framepos(xcount , Yb , 1)
      Call Glcd_pixpos(xcount , Yb , 1)
   Next A
End Sub