Datasheet
'-------------- Opens an existing file and rewrites it
sub procedure Open_File_Rewrite
filename[7] = "C" ' Set filename for single-file tests
Mmc_Fat_Assign(filename, 0)
Mmc_Fat_Rewrite
for loop_ = 1 to 55
file_contents[0] = byte(loop_ div 10 + 48)
file_contents[1] = byte(loop_ mod 10 + 48)
Mmc_Fat_Write(file_contents, 42) ' write data to the assigned
file
next loop_
end sub'~
'-------------- Opens an existing file and appends data to it
' (and alters the date/time stamp)
sub procedure Open_File_Append
filename[7] = "B"
Mmc_Fat_Assign(filename, 0)
Mmc_Fat_Set_File_Date(2005,6,21,10,35,0)
Mmc_Fat_Append() ' Prepare file for append
file_contents = " for mikroElektronika 2007" ' Prepare file
for append
file_contents[26] = 10 ' LF
Mmc_Fat_Write(file_contents, 27) ' Write data to assigned file
end sub'~
'-------------- Opens an existing file, reads data from it and puts
it to USART
sub procedure Open_File_Read
filename[7] = "B"
Mmc_Fat_Assign(filename, 0)
Mmc_Fat_Reset(size) ' To read file, sub proce-
dure returns size of file
while size > 0
Mmc_Fat_Read(character)
UART1_Write(character) ' Write data to USART
Dec(size)
wend
end sub'~
'-------------- Deletes a file. If file doesn"t exist, it will first
be created
' and then deleted.
sub procedure Delete_File
filename[7] = "F"
Mmc_Fat_Assign(filename, 0)
Mmc_Fat_Delete
end sub'~
277
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6