Hi pebisoft!

OK.
Aber wenn du nur noch auf MCUCam-Trip bist, dann kannst du mir ja deine GBC verkaufen...
Die Platinen.......................................... ... .

Der jetzige Code ist folgender:
Code:
$regfile = "m8def.dat"                                      'ATmega8-Deklarationen
$crystal = 16000000                                         'Quarz: 16 MHz
$baud = 9600                                                'Baudrate der UART: 9600 Baud, 8N1

Dim A As Byte
Dim I As Byte

Dim Adcv As Byte

Dim Msb As Byte
Dim Lsb As Byte

Dim Regadr As Byte
Dim Regvalue As Byte

Dim C0 As Byte
Dim C1 As Byte
Dim G As Byte
Dim O As Byte


Dim Rda As Word


Config Adc = Single , Prescaler = Auto


Declare Function Laybus(byval Value As Byte) As Byte
Declare Function Readbus() As Byte
Declare Sub Writeram()
Declare Sub Readramstart()
Declare Sub Readramstop()
Declare Sub Flashadrlsb()
Declare Sub Flashadrmsb()
Declare Sub Formatram()

Declare Sub Resetcam()
Declare Sub Loadreg()
Declare Sub Camimp()
Declare Sub Capture()
Declare Sub Camdelay()


Ddrb = &B00111111                                           'Alles Ausgaenge :D    (Ausser QUARZ!)
Ddrc = &B11111111                                           'Die auch
Ddrd = &B11101111                                           'und da bin ich noch nciht ganz sicher.

A = Laybus(0)                                               'Bus auf 00000000 (=0x00) setzen

Portd.7 = 1                                                 'Outputenable Active: LOW
Portd.6 = 1                                                 'WriteEnable Active: LOW

Portc.2 = 0                                                 'LATCH ENABLE des LSB vom Adressbus/RAM ACTIVE HIGH
Portc.3 = 0                                                 'LATCH ENABLE des MSB vom Adressbus/RAM ACTIVE HIGH


Portc.4 = 0                                                 'Start, -et Aufnahmeprozess (HIGH)
Portc.5 = 0                                                 'Sin, daten f. Register (HIGH)
Portd.2 = 0                                                 'Load, Speichern Register (HIGH)                                                    'Reset, System + Speicherreset
Portd.3 = 1                                                 'Reset, Speicher + Systemreset (LOW)
Portd.5 = 0                                                 'XCK, Taktleitung

      'Portd.4                                                     'READ, Zeigt, Ob Bild vorliegt



Call Formatram()

Print ""
Print "======================================================="
Print "                      CAMTEST.bas                      "
Print "              Testet die Camera für LOG                "
Print "             Testphase3: Kamera auslesen.              "
Print "======================================================="
Print ""

Print "Protocol:"
Print ""

I = 0
A = 0


'1.: Auslösen eines Resets
   Call Resetcam()

   'Print "CAM resetted"


   A = Laybus(0)

'2.: Laden der Register.

Startproc:

   Print "Bitte geben sie C1 (Reg 2 MSB) ein:"


   Do
      If Ucsra.rxc = 1 Then
         C1 = Udr
         A = 255
      End If
   Loop Until A <> 0

   A = 0

   Print "C1 beträgt: " ; C1




   Print "Bitte geben sie C0 (Reg 3 LSB) ein:"

   Do
      If Ucsra.rxc = 1 Then
         C0 = Udr
         A = 255
      End If
   Loop Until A <> 0

   A = 0

   Print "C0 beträgt: " ; C0




   Print "Bitte geben sie G (Reg 1) ein:"

   Do
      If Ucsra.rxc = 1 Then
         G = Udr
         A = 255
      End If
   Loop Until A <> 0

   A = 0

   Print "Gain beträgt: " ; G




   Print "Bitte geben sie O (Reg 0) ein:"

   Do
      If Ucsra.rxc = 1 Then
         O = Udr
         A = 255
      End If
   Loop Until A <> 0

   A = 0

   Print "Offest beträgt: " ; O




   Print ""
   Print "Beginne in 5 Sekunden!"

   Wait 8



   Regadr = 1                                               'Register NUMMER 1:
   Regvalue = G
   Call Loadreg()

   Regadr = 2                                               'Register NUMMER 2:
   Regvalue = C1
   Call Loadreg()

   Regadr = 3                                               'Register NUMMER 3:
   Regvalue = C0
   Call Loadreg()


   Regadr = 4                                               'Register NUMMER 4:
   Regvalue = 1
   Call Loadreg()

   Regadr = 5                                               'Register NUMMER 5:
   Regvalue = 0
   Call Loadreg()

   Regadr = 6                                               'Register NUMMER 6:
   Regvalue = 1
   Call Loadreg()

   Regadr = 7                                               'Register NUMMER 7:
   Regvalue = 7
   Call Loadreg()


   Regadr = 0                                               'Register NUMMER 0:
   Regvalue = O
   Call Loadreg()

   'Print "Registers loaded."




   '3. : Bild machen :D
   Call Capture()

   'Print "Startsignal done."



   '4. : auf de voll krass Bild warten ey!

   'Print "creating wait-clock"

   I = 0

   Do
      Call Camimp()
      I = I + 1

   Loop Until Pind.4 = 1

   'Print "Camera ready. Clocks created: " ; I


    Call Camdelay()



   '5. : voll krass de bild abhole, ey! ;D       www.stophiphop.de Evolution. Mit uns. gegen HipHop.

   'Print "ADC-Werte:"
   'Print ""

   Rda = 0

   Do

    Portd.5 = 0
    Portd.5 = 1

    Call Camdelay()

    Portd.5 = 0

    Start Adc
       Adcv = Getadc(7)
    Stop Adc

    'RAM-Prozedur
    Rda = Rda + 1

    Msb = High(rda)
    A = Laybus(msb)
    Call Flashadrmsb()

    Lsb = Low(rda)
    A = Laybus(lsb)
    Call Flashadrlsb()

    A = Laybus(adcv)
    Call Writeram()
    'ENDE RAM


    Waitus 2

   Loop Until Pind.4 = 0




   Rda = 0

   For Rda = 0 To 16384

    Msb = High(rda)
    A = Laybus(msb)
    Call Flashadrmsb()

    Lsb = Low(rda)
    A = Laybus(lsb)
    Call Flashadrlsb()

    Call Readramstart()

    Adcv = Readbus()

    Call Readramstop

    Printbin Adcv
    Printbin 59

    Waitms 3

   Next


   A = Laybus(0)


   Printbin 255

 Call Formatram()
 Wait 2
Goto Startproc


End
'===============================================================================================




Function Laybus(byval Value As Byte)

   Ddrb = &B00111111                                        'Alles Ausgaenge :D    (Ausser QUARZ!)
   Ddrc = &B11111111                                        'Die auch,

   Portc.1 = Value.0
   Portc.0 = Value.1
   Portb.5 = Value.2
   Portb.4 = Value.3
   Portb.3 = Value.4
   Portb.2 = Value.5
   Portb.1 = Value.6
   Portb.0 = Value.7

End Function


Function Readbus()
   Dim Value As Byte

   Ddrb = &B00000000                                        'Alles Ausgaenge :D    (Ausser QUARZ!)
   Ddrc = &B11111100                                        'Die auch

   Value.0 = Pinc.1
   Value.1 = Pinc.0
   Value.2 = Pinb.5
   Value.3 = Pinb.4
   Value.4 = Pinb.3
   Value.5 = Pinb.2
   Value.6 = Pinb.1
   Value.7 = Pinb.0

   Readbus = Value

End Function


Sub Writeram()

   Portd.6 = 1
   Portd.6 = 0                                              'ACTIVE LOW
   Portd.6 = 1

End Sub



Sub Readramstart()

   Portd.7 = 1
   Portd.7 = 0                                              'ACTIVE LOW

End Sub


Sub Readramstop()

   Portd.7 = 1

End Sub


Sub Flashadrlsb()

   Portc.2 = 0
   Portc.2 = 1                                              'Active HIGH
   Portc.2 = 0

End Sub


Sub Flashadrmsb()

   Portc.3 = 0
   Portc.3 = 1                                              'ACTIVE HIGH
   Portc.3 = 0

End Sub


Sub Formatram()

   Msb = 0
   Lsb = 0

   Do

   Lsb = Lsb + 1

   If Lsb = 255 Then
      Msb = Msb + 1
      Lsb = 0
   End If


   A = Laybus(msb)
   Call Flashadrmsb()

   A = Laybus(lsb)
   Call Flashadrlsb()

   A = Laybus(0)
   Call Writeram()


   If Msb = 255 Then
      Exit Do
   End If

   Loop


End Sub







Sub Resetcam()

 Ddrc = &B11111111                                          'Die auch
 Ddrd = &B11101111                                          'und da bin ich noch nciht ganz sicher.

   Portd.3 = 1
   Portd.5 = 0
      Call Camdelay()
   Portd.3 = 0
      Call Camdelay()
   Portd.5 = 1
      Call Camdelay()
   Portd.3 = 1
      Call Camdelay()
   Portd.5 = 0

End Sub


Sub Camimp()

   Portd.5 = 0
   Portd.5 = 1
      Call Camdelay()
   Portd.5 = 0
      Call Camdelay()

End Sub


Sub Loadreg()
   Dim Iii As Byte

   'Print Regadr ; ": " ; Regvalue

  'Erst: Adresse:

  Portd.5 = 0
  Portc.5 = Regadr.0
   Call Camdelay()
  Portd.5 = 1
   Call Camdelay()
  Portc.5 = 0
   Call Camdelay()
  Portd.5 = 0


   Call Camdelay()

  Portc.5 = Regadr.1
   Call Camdelay()
  Portd.5 = 1
   Call Camdelay()
  Portc.5 = 0
   Call Camdelay()
  Portd.5 = 0

   Call Camdelay()


  Portc.5 = Regadr.2
   Call Camdelay()
  Portd.5 = 1
   Call Camdelay()
  Portc.5 = 0
   Call Camdelay()
  Portd.5 = 0

     'Call Camdelay()

  '=====================0

  For Iii = 7 To 0 Step -1

    If Iii = 0 Then
     Portd.5 = 0
     Portc.5 = Regvalue.iii
     Waitus 5
     Portd.5 = 1
        Call Camdelay()

     Portd.2 = 0
     Portd.2 = 1

        Call Camdelay()
     Portd.5 = 0
     Portc.5 = 0

        Call Camdelay()
     Portd.2 = 0

     Exit For
    End If

  Portd.5 = 0
  Portc.5 = Regvalue.iii
  Waitus 5
  Portd.5 = 1
   Call Camdelay()
  Portc.5 = 0
   Call Camdelay()
  Portd.5 = 0

  Call Camdelay()




  Next



  'Call Camimp()

End Sub


Sub Capture()

     ' Call Camdelay()

   Portc.4 = 0
   Portd.5 = 0

   Portc.4 = 1
      Call Camdelay()
   Portd.5 = 1
      Call Camdelay()
   Portc.4 = 0
      Call Camdelay()
   Portd.5 = 0


End Sub


Sub Camdelay()

   Waitus 5

End Sub
Bitte schaut auch nach Fehlern!! Ich bin nicht sicher, ob da nicht der ein oder andere Fehler dabei ist!

Da können/müssen welche drin sein, sonst müsste ich ja Bilder kriegen wie Kjion!

Viele liebe Grüße,
Tobi