Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

f_open(&fdst, "0:dstfile.txt", FA_CREATE_ALWAYS | FA_WRITE)

Status
Not open for further replies.

anhnha

Full Member level 6
Joined
Mar 8, 2012
Messages
322
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,298
Activity points
3,690
May be this is a stupid question but i cannot figure out, hope anyone can help.
After i use f_open() to create dstfile.txt, where i can find this file? I think that it must be located in C disk but I dont see any file is created.
res = f_open(&fdst, "C:\\dstfile.txt", FA_CREATE_ALWAYS | FA_WRITE);
PS: This function is in FATFS library here: http://elm-chan.org/fsw/ff/00index_e.html
 

Joined
Jul 25, 2012
Messages
1,192
Helped
170
Reputation
340
Reaction score
161
Trophy points
1,343
Activity points
0
Is it not a function to create file on SD cards? If you are simulating in Proteus the file will be created in the .mmc file.

Is it res = f_open(&fdst, "C:\\dstfile.txt", FA_CREATE_ALWAYS | FA_WRITE); or res = f_open(&fdst, "C:\dstfile.txt", FA_CREATE_ALWAYS | FA_WRITE);

It might be res = f_open(&fdst, "C:dstfile.txt", FA_CREATE_ALWAYS | FA_WRITE);

It is clearly mentioned that

/* Create destination file on the drive 0 */
res = f_open(&fdst, "0:dstfile.dat", FA_CREATE_ALWAYS | FA_WRITE);
 
Last edited:

anhnha

Full Member level 6
Joined
Mar 8, 2012
Messages
322
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,298
Activity points
3,690
Thank you again, internetuser2k12 :lol:
I am trying to learn how to use fatfs function and the bellow is code that I used:
Code:
int main (void)
{
	
FATFS fs1;         /* Work area (file system object) for logical drive */
FIL fsrc1;         /* file objects */   
FRESULT res1;
UINT br1;


char date[30]="Date : ", _time[30]="Time : ";
   
char pathname[50]="0:/Sell/";
uint8_t textFileBuffer[8]= "write to file" ; 
			res1 = f_open( &fsrc1 , "C:\\Demo.TXT" , FA_CREATE_NEW | FA_WRITE);		
    	if ( res1 == FR_OK )
    	{ 
      		// Write buffer to file 
      		res1 = f_write(&fsrc1, textFileBuffer, sizeof(textFileBuffer), &br1);     
 			printf("Demo.TXT successfully created        \r\n");
    		//close file 
      		f_close(&fsrc1);      
    	} else 
		if ( res1 == FR_EXIST )
    	{
	  		printf("Demo.TXT created in the disk      \r\n");
    	} 
			 
    }
I think it must create a file Demo.TXT in C disk and write "write to file" string into it but when i look C disk, i didn't see any file created.
PS: I will use these function for my sd card but now i want to test these functions.
 

Joined
Jul 25, 2012
Messages
1,192
Helped
170
Reputation
340
Reaction score
161
Trophy points
1,343
Activity points
0
Are you running your code on PIC? If yes where is C drive in it? If you are simulatinf in Proteus then there is no Drive in .mmc file. If you are creating file on SD card then SD card is not your c drive.

Are you writing a c program for your PC to create file on C drive using FAtfs library?
 

anhnha

Full Member level 6
Joined
Mar 8, 2012
Messages
322
Helped
4
Reputation
8
Reaction score
4
Trophy points
1,298
Activity points
3,690
Here is what I am doing:
1.I downloaded FatFs sample projects from here: http://elm-chan.org/fsw/ff/00index_e.html
2. I used avr from that file and modifies main.c into sample2.c
3. Then I complied this project in avr studio without error.
But now I cannot find any file that is created as the code above!
 

Attachments


Joined
Jul 25, 2012
Messages
1,192
Helped
170
Reputation
340
Reaction score
161
Trophy points
1,343
Activity points
0
How can your PIC read the drive system of your PC when you are simulating in proteus?

Can you show how you have used f_mount();? It says drive should be 0 to 9 it is a number not something like C:\\
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top