Datasheet

filename[7] = "C" ' Set filename for single-file tests
Cf_Fat_Assign(filename, 0)
Cf_Fat_Rewrite
for loop_ = 1 to 55
file_contents[0] = byte(loop_ div 10 + 48)
file_contents[1] = byte(loop_ mod 10 + 48)
Cf_Fat_Write(file_contents, 38) ' 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"
Cf_Fat_Assign(filename, 0)
Cf_Fat_Set_File_Date(2005,6,21,10,35,0)
Cf_Fat_Append
file_contents = " for mikroElektronika 2005" ' Prepare file
for append
file_contents[26] = 10 ' LF
Cf_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"
Cf_Fat_Assign(filename, 0)
Cf_Fat_Reset(size) ' To read file, sub procedure returns
size of file
while size > 0
Cf_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"
Cf_Fat_Assign(filename, 0)
Cf_Fat_Delete
end sub'~
'-------------- Tests whether file exists, and if so sends its cre-
ation date
' and file size via USART
207
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6