Hallo zusammen,
ich hab diesen Thread mit Interesse gelesen und er hat mich auch soweit gebracht, dass eine Datei über den ATMega32 auf meiner SD-Karte (1GB) angelegt wird.
Mehr ist allerdings nicht drin, sprich: der speichert nix drinnen.
Ich hab den Beispiel-Quellcode aus diesem Thread verwendet und die includes entsprechend angepasst:
Code:
$regfile = "m32def.dat"
$crystal = 16000000
' Adjust HW Stack, Soft-Stack and Frame size to 128 minimum each!!!
$baud = 9600
'Open "Com1:" As Binary As #1 ' use #1 for fs_interpreter
Config Clock = Soft
Enable Interrupts
Config Date = Mdy , Separator = .
Dim Btemp1 As Byte
Wait 3
Print "Wait for Drive"
$include "Config_MMC.bas"
' Include here you driver for Compactflash/HardDisk or other
'$include "Config_CompactFlash_M128.bas" ' Does drive init too
'$Include "Config_HardDisk_M128.bas"
If Gbdriveerror = 0 Then
' Include AVR-DOS Configuration and library
$include "Config_AVR-DOS.BAS"
Print "Init File System ... ";
Btemp1 = Initfilesystem(1) ' Partition 1
' use 0 for drive without Master boot record
If Btemp1 <> 0 Then
Print "Error: " ; Btemp1 ; " at Init file system"
Else
Print " OK"
Print "Filesystem: " ; Gbfilesystem
Print "FAT Start Sector: " ; Glfatfirstsector
Print "Root Start Sector: " ; Glrootfirstsector
Print "Data First Sector: " ; Gldatafirstsector
Print "Max. Cluster Nummber: " ; Glmaxclusternumber
Print "Sectors per Cluster: " ; Gbsectorspercluster
Print "Root Entries: " ; Gwrootentries
Print "Sectors per FAT: " ; Glsectorsperfat
Print "Number of FATs: " ; Gbnumberoffats
Print "Disksize : " ; Disksize() ' show disk size in bytes
'Print "Disk free: " ; Diskfree()
Print "File Len: " ; Filelen( "TEST3.TXT") ' show free space too
End If
Else
Print "Error during Drive Init: " ; Gbdriveerror
End If
'File erstellen und etwas reinschreiben
'dim some test variables
Dim S As String * 60 , Fl As String * 12 , Ff As Byte
Dim X As Byte
Dim I As Word
Dim Sdatetime As String * 18
Fl = "test3.txt"
S = "test this"
'Now we are getting to it
'We can specify a file handle with #1 or #2 etc. or we can ask for a free
' file handle with the FreeFile function. It will return a free handle if there is one.
Ff = Freefile() ' get a file handle
'With this file handle we refer to a file
'Open Fl For Output As #ff ' open fikle for output
Open Fl For Output As #ff
' we need to open a file before we can use the file commands
' we open it for OUTPUT, INPUT , APPEND or BINARY
' In this case we open it for OUTPUT because we want to write to the file.
' If the file existed, the file would be overwritten.
Print #ff , "A constant"
'Testsb Ff
Put #ff , S
Write #ff , "Write test"
Flush #ff
Close #ff
Print "fertig"
End
' If you want to test with File-System Interpreter uncomment next line
'$include "FS_Interpreter.bas"
Den Schaltplan von der SD-Karten-Platine sowie meine include-files habe ich auch mal hochgeladen.
Wäre sehr dankbar, falls jemand eine Idee hätte, woran das liegen könnte.
So long und viele Grüße!
Lesezeichen