Datasheet
for loop := 1 to 55 do
begin
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
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';
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;
//-------------- Opens an existing file, reads data from it and puts
it to USART
procedure Open_File_Read;
begin
filename[7] := 'B';
Cf_Fat_Assign(filename, 0);
Cf_Fat_Reset(size); // To read file, procedure returns
size of file
while size > 0 do begin
Cf_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.
procedure Delete_File;
begin
filename[7] := 'F';
Cf_Fat_Assign(filename, 0);
Cf_Fat_Delete;
end;
//-------------- Deletes a file. If file doesn't exist, it will first
be created
222
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6