Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics 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.

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,684
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
 

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:

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.
 

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?
 

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

  • sample2.rar
    388.8 KB · Views: 94

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

Back
Top