DSPRelated.com
Forums

Writing data to SDRAM

Started by ebraidotti November 23, 2004


Hi guys,

need HELP!!! I have a project to give to my professor on Wednesday,
i'm done with everyting on my c6711DSK board but i can't load a .mp3
file on the DSK SDRAM memory...the file is really small (just 7 K)
but still it doesn't put it into memory...
These are the lines in C language I wrote to get to load the file...i
made a few changes on them but still it doesn't work...
Can somebody tell me why or just give me an easier way to transfer
this little .mp3 file to memory...
I tried even with the File I/O option on CC Studio 2.1 but it lets me
transfer only .dat or .coff files... (the UINT was defined of type unsigned int (32-bit long))

void load_file (UINT *data, UINT *end_file)
{
UINT *data, *end_file;
data=0;
end_file=0;
data=malloc(sizeof(UINT [2048])); //are 8 KB
FILE *fp;
char nome_file [255];
UINT *data_temp;
int i=1;
int test=0;
printf("load_file \n");
data_tempa;
printf("Insert the name of the file to load (with path)\n");
printf("(example: C:\\myfolder\\song.mp3)\n");
printf("file: ");
scanf(nome_file);
if((fp=fopen(nome_file, "r+b")) == NULL)
{
printf("Impossibile to open the file \n");
return;
}

printf("Loading ");

do{
if (feof(fp)) {
i=0;
end_filea_temp;
}
else
i=fread(data_temp, 4, 1, fp);

#ifdef MP3Debug
if((test % 50) == 0)
printf(".");
test++;
#endif

data_temp++;
} while (i==1);
// } while (i);

fclose(fp);

printf("\n File LOADED \n");
} Thanks in advance to everybody...in advance...

-Enrico




Hello Enrico,
 
A couple of comments...
[NOTE: I haven't looked at your code in detail and don't plan on doing your assignment for you - not to mention that your professor monitors this newsgroup.]
 
One of the most important aspects of asking for help is to "paint a picture of the problem" so that others may visualize what is going on.  I do not have a clue what is going on except that "it doesn't work".
 
Does the file get opened or do you get 'impossible to open' message??
It isn't clear from your message.
Does your program appear to run correctly, but the data "isn't there"??
How did you verify that the data "wasn't there"??
 
Assuming thatyour program 'looks like its runs okay', but you did not see the data...
Did you try setting a breakpoint on 'fclose' and displaying mem beginning at data??
Hint: It is often helpful to use calloc instead of malloc during troubleshooting.
Hint: If you are troubleshooting a 'file read problem', it sometimes helps to use a different file that is easily recognizeable in memory.
 
Good Luck,
mikedunn

ebraidotti <e...@yahoo.com> wrote:
Hi guys,

need HELP!!! I have a project to give to my professor on Wednesday,
i'm done with everyting on my c6711DSK board but i can't load a .mp3
file on the DSK SDRAM memory...the file is really small (just 7 K)
but still it doesn't put it into memory...
These are the lines in C language I wrote to get to load the file...i
made a few changes on them but still it doesn't work...
Can somebody tell me why or just give me an easier way to transfer
this little .mp3 file to memory...
I tried even with the File I/O option on CC Studio 2.1 but it lets me
transfer only .dat or .coff files...(the UINT was defined of type unsigned int (32-bit long))

void load_file (UINT *data, UINT *end_file)
{
UINT *data, *end_file;
data=0;
end_file=0;
data=malloc(sizeof(UINT [2048])); //are 8 KB
FILE *fp;
char nome_file [255];
UINT *data_temp;
int i=1;
int test=0;
printf("load_file \n");
data_tempa;
printf("Insert the name of the file to load (with path)\n");
printf("(example: C:\\myfolder\\song.mp3)\n");
printf("file: ");
scanf(nome_file);
if((fp=fopen(nome_file, "r+b")) == NULL)
{
printf("Impossibile to open the file \n");
return;
}

printf("Loading ");

do{
if (feof(fp)) {
i=0;
end_filea_temp;
}
else
i=fread(data_temp, 4, 1, fp);

#ifdef MP3Debug
if((test % 50) == 0)
printf(".");
test++;
#endif

data_temp++;
} while (i==1);
// } while (i);

fclose(fp);

printf("\n File LOADED \n");
}Thanks in advance to everybody...in advance...

-Enrico_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group.

_____________________________________
About this discussion group:

To Join: Send an email to c...@yahoogroups.com

To Post: Send an email to c...@yahoogroups.com

To Leave: Send an email to c...@yahoogroups.com

Archives: http://www.yahoogroups.com/group/c6x

Other Groups: http://www.dsprelated.com

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/c6x/

<*> To unsubscribe from this group, send an email to:
c...@yahoogroups.com

<*