User manual
294
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
le_contents[0] := byte(loop div 10 + 48);
le_contents[1] := byte(loop mod 10 + 48);
Cf_Fat_Write(le_contents, LINE_LEN-1); // write data to the assigned le
end;
end;
//-------------- Opens an existing le and appends data to it
// (and alters the date/time stamp)
procedure M_Open_File_Append();
begin
lename[7] := ‘B’;
Cf_Fat_Assign(lename, 0);
Cf_Fat_Set_File_Date(2009, 1, 23, 17, 22, 0);
Cf_Fat_Append;
le_contents := ‘ for mikroElektronika 2007’; // Prepare le for append
le_contents[26] := 10; // LF
Cf_Fat_Write(le_contents, 27); // Write data to assigned le
end;
//-------------- Opens an existing le, reads data from it and puts it to USART
procedure M_Open_File_Read();
begin
lename[7] := ‘B’;
Cf_Fat_Assign(lename, 0);
Cf_Fat_Reset(size); // To read le, procedure returns size of le
while size > 0 do
begin
Cf_Fat_Read(character);
UART1_Write(character); // Write data to USART
Dec(size);
end;
end;
//-------------- Deletes a le. If le doesn’t exist, it will rst be created
// and then deleted.
procedure M_Delete_File();
begin
lename[7] := ‘F’;
Cf_Fat_Assign(lename, 0);
Cf_Fat_Delete();
end;
//-------------- Tests whether le exists, and if so sends its creation date
// and le size via USART
procedure M_Test_File_Exist();
var
fsize : longint;
year : word;
month, day, hour, minute : byte;
outstr : array[12] of char;
begin
lename[7] := ‘B’; // uncomment this line to search for le that DOES exists