User manual
mikroPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
403
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’;
Mmc_Fat_Assign(lename, 0);
Mmc_Fat_Set_File_Date(2009, 1, 23, 17, 22, 0);
Mmc_Fat_Append(); // Prepare le for append
le_contents := ‘ for mikroElektronika 2007’; // Prepare le for append
le_contents[26] := 10; // LF
Mmc_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’;
Mmc_Fat_Assign(lename, 0);
Mmc_Fat_Reset(size); // To read le, procedure returns size of le
while size > 0 do
begin
Mmc_Fat_Read(character);
UART1_Write(character); // Write data to UART
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’;
Mmc_Fat_Assign(lename, 0);
Mmc_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’;
if Mmc_Fat_Assign(lename, 0) <> 0 then begin
//--- le has been found - get its date
Mmc_Fat_Get_File_Date(year,month,day,hour,minute);
UART1_Write_Text(‘ created: ‘);
WordToStr(year, outstr);
UART1_Write_Text(outstr);
ByteToStr(month, outstr);
UART1_Write_Text(outstr);
WordToStr(day, outstr);