M_Open_File_Append (); does not work.

General discussion on mikroC.
Post Reply
Author
Message
picluigi
Posts: 17
Joined: 23 Jan 2009 20:56

M_Open_File_Append (); does not work.

#1 Post by picluigi » 12 Jun 2011 21:44

This is my code:

#include <built_in.h>

char
FAT_ERROR[20] = "FAT16 not found",
file_contents[50] = "XX MMC/SD FAT16 library by Luigi Rieckert\n";
char cont;
char
filename[14] = "MIKRO00xTXT"; // File names
unsigned short
tmp, caracter, loop, loop2;
unsigned long
i, size;

void I_Write_Str(char *ostr) {
unsigned short i;

i = 0;
while (ostr) {
USART_Write(ostr[i++]);
}
USART_Write(0x0A);
}//~
//M-M-M--------- Creates new file and writes some data to it
void M_Create_New_File() {
filename[7] = 'A';
Mmc_Fat_Assign(&filename, 1); // Will not find file and then create file
Mmc_Fat_Rewrite(); // To clear file and start with new data
Mmc_Fat_Write(file_contents, 42); // write data to the assigned file
}
//M-M-M--------- Opens an existing file and appends data to it
// (and alters the date/time stamp)
void M_Open_File_Append() {
filename[7] = 'B';
Mmc_Fat_Assign(&filename, 0);
Mmc_Fat_Set_File_Date(2005,6,21,10,35,0);
Mmc_Fat_Append();
PORTD = 0x08; // Prepare file for append
Mmc_Fat_Write(" for mikroElektronika 2005\n", 27); // Write data to assigned file
}//~

void main() {
//--- prepare PORTB for signalling
PORTB = 0;
TRISB = 0x10;
INTCON2.F7=0;
TRISD = 0x00;
TRISC = 0xD3;
//--- init the FAT library
Spi_Init_Advanced(MASTER_OSC_DIV16, DATA_SAMPLE_MIDDLE, CLK_IDLE_LOW, LOW_2_HIGH);





if (Mmc_Fat_Init(&PORTC,2))
{
//--- Test start
PORTD = 0xF0;
//--- Test routines. Uncomment them one-by-one to test certain features


//M_Create_New_File();
M_Open_File_Append();
}

else {
I_Write_Str(FAT_ERROR);
}
//--- Test termination
PORTD = 0x0F;


}//~!


if I use the function: M_Create_New_File (); all right.
if I use the function: M_Open_File_Append (); does not work.
Why?
My compiler is mikroC v.6.2
The device is P18F458 HSPLL = 40MHz with quartz 10MHz.
Thanks, Regards.

User avatar
slavisa.zlatanovic
mikroElektronika team
Posts: 1321
Joined: 07 Apr 2009 09:39

Re: M_Open_File_Append (); does not work.

#2 Post by slavisa.zlatanovic » 13 Jun 2011 09:58

Hi!

We strongly encourage users to switch to PRO version because non-PRO version is an ancestor of PRO compiler
and is no longer being developed.
Every new feature, improvement and bug fix will only affect new versions of PRO compilers.
If you're a registered user you'll receive PRO license key free of charge.
Best regards
Slavisa

Post Reply

Return to “mikroC General”