Datasheet
end;//~
//-------------- Opens an existing file and rewrites it
procedure Open_File_Rewrite;
begin
filename[7] := 'C'; // Set filename for single-file tests
Mmc_Fat_Assign(filename, 0);
Mmc_Fat_Rewrite;
for loop := 1 to 55 do
begin
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
end;
end;//~
//-------------- Opens an existing file and appends data to it
// (and alters the date/time stamp)
procedure Open_File_Append;
begin
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;//~
//-------------- Opens an existing file, reads data from it and puts
it to USART
procedure Open_File_Read;
begin
filename[7] := 'B';
Mmc_Fat_Assign(filename, 0);
Mmc_Fat_Reset(size); // To read file, procedure
returns size of file
while size > 0 do
begin
Mmc_Fat_Read(character);
UART1_Write(character); // Write data to USART
Dec(size);
end;
end;//~
//-------------- Deletes a file. If file doesn't exist, it will first
be created
// and then deleted.
290
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6