Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: SD Memory Card Interface using FAT16/FAT32 and SPI
PostPosted: Mon Mar 16, 2009 10:46 pm 
Offline

Joined: Tue Mar 10, 2009 7:55 am
Posts: 7
hello all;
I am going to design a datalogger project and I need to save the data on a SD card in FAT16 or FAT32 format (so I can read the files in PC). has anyone any code or library for that purpose. Of course the micro must use SPI for communicating with the SD memory card. I am working with AT91sam7x256 and I am using Keil compiler.
Thanks in advance.


Top
 Profile  
 
 Post subject: Re: SD Memory Card Interface using FAT16/FAT32 and SPI
PostPosted: Tue Mar 17, 2009 4:36 pm 
Offline

Joined: Fri Oct 24, 2008 5:31 pm
Posts: 31
hello, for using fat library there is some free lib for using. but i'd edited one of them for IAR Embeded workbench but i think you can edit it for keil,
and for interfacing sd with at91sam7x256 you can use atmel example code.
it's for keil, iar and gnu.

here is the link:

http://www.atmel.com/dyn/resources/prod ... m7x-ek.zip

it's 40mb

good luck!


Attachments:
fat.rar [206.07 KiB]
Downloaded 346 times
Top
 Profile  
 
 Post subject: Re: SD Memory Card Interface using FAT16/FAT32 and SPI
PostPosted: Wed Mar 18, 2009 7:51 am 
Offline

Joined: Tue Mar 10, 2009 7:55 am
Posts: 7
black-scorpion wrote:
hello, for using fat library there is some free lib for using. but i'd edited one of them for IAR Embeded workbench but i think you can edit it for keil,
and for interfacing sd with at91sam7x256 you can use atmel example code.
it's for keil, iar and gnu.

here is the link:

http://www.atmel.com/dyn/resources/prod ... m7x-ek.zip

it's 40mb

good luck!


Thanks for your reply and for the example code that you mentioned;
I will try to edit the library for Keil and I will also try to use the example code and then I will inform everybody of the results.
Thanks


Top
 Profile  
 
 Post subject: Re: SD Memory Card Interface using FAT16/FAT32 and SPI
PostPosted: Thu Apr 02, 2009 3:26 am 
Offline

Joined: Thu Apr 02, 2009 12:44 am
Posts: 2
Hello.... I am a total starter at this.... I`m using AT91SAM7X-EK evaluation kin with SAM7X256 MCU. I have downloaded your code, but file processor.h file is missing ,it is requsted in mmc.c file.... what kind of library is that or where can i find it. It would be great if you could send me some example code, that would just create some file, write a few bytes... and close the file...


Top
 Profile  
 
 Post subject: Re: SD Memory Card Interface using FAT16/FAT32 and SPI
PostPosted: Fri Apr 03, 2009 12:44 am 
Offline

Joined: Fri Oct 24, 2008 5:31 pm
Posts: 31
hi, in these project no processor.h needed, plz delete this header file from #include.


Top
 Profile  
 
 Post subject: Re: SD Memory Card Interface using FAT16/FAT32 and SPI
PostPosted: Sun Apr 26, 2009 11:17 pm 
Offline

Joined: Thu Apr 02, 2009 12:44 am
Posts: 2
Hi... please help, I still can't get it to work, i get error on compilation that there are no definitions for diskio functions (getfattime, disk read etc...), please help (example code would be very helpful), I think I ran out of beginners luck :(


Top
 Profile  
 
 Post subject: Re: SD Memory Card Interface using FAT16/FAT32 and SPI
PostPosted: Fri May 01, 2009 8:46 pm 
Offline

Joined: Fri Oct 24, 2008 5:31 pm
Posts: 31
hello, there is one topic that i created it for other that help me to complete my program for correcting the erorrs, see it at this topic:

viewtopic.php?f=15&t=12756


Top
 Profile  
 
 Post subject: Re: SD Memory Card Interface using FAT16/FAT32 and SPI
PostPosted: Tue Nov 09, 2010 11:31 pm 
Offline

Joined: Thu Jan 31, 2008 10:34 pm
Posts: 2
Location: iran
Hi everyone
I used the Fat Library.It works Corectly but I have just one problem.f_write function doesn't work correctly and it doesn't return FR_OK.Can somebody help me?It creates new file and it read an existing file but it can't write to a file.this is my code:

#include "project.h"
#include "Demo.h"
#include "Font.h"
#include "t6963c.h"

#include "mmc.c"
#if TINY_FAT
#include "tff.c"
#else
#include "ff.c"
#endif



WORD mmc_ok=0,n;
char filename[20]="test.txt";
char str[512]="File Writing Is OK!!!!!!!!";
FATFS fat;
FIL file;
//***************************************************************
void InitDevice()
{
AT91C_BASE_RSTC->RSTC_RMR=0xA5000000 | AT91C_RSTC_URSTEN; //Enable External RESET
}
//***************************************************************

void main()
{
InitDevice();
LCD_Setup();
LCD_Init();
LCD_ClearText();
LCD_ClearGraph();

if(disk_initialize(0)!=STA_NOINIT)
{
//xmit_datablock(str, 0xFE)
LCD_Print(0,0,"MMC Init OK");
mmc_ok=1;
f_mount(0,&fat);
}
else
LCD_Print(10,7,"MMC Not Init");

if(mmc_ok)
{
if(f_open(&file,filename,FA_CREATE_ALWAYS | FA_WRITE)==FR_OK) //Create A New File
{
f_sync(&file);

if(f_write(&file,str,10,&n)==FR_OK) //Writin To Opened File
LCD_Print(0,3,"File Writing OK");
else
LCD_Print(0,3,"File Writing Error");

f_close(&file); //Close Opened File
if(f_open(&file,filename,FA_OPEN_EXISTING | FA_READ)==FR_OK)
LCD_Print(0,4,"File Open For Read OK");
else
LCD_Print(0,4,"File Open Error");
f_sync(&file);

str[0]='\0';
if(f_read(&file,str,50,&n)==FR_OK) //Reading From Opened File
{
LCD_Print(0,6,"File Readig OK");
str[50]='\0';
LCD_Print(0,8,str);
}
else
LCD_Print(0,6,"File Reading Error");
}
}
while(1)
{

}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: