Reply by lim chen hui November 20, 20092009-11-20
> To speed up fread()
>
> 1. Ensure that cache and SDRAM are setup correctly.
> 2. Use large blocks [one huge one, if possible]. CCS and the OS might
> break them up behind the scenes, but we cannot do anything about that.

Do you mean assign large amount of memory for cache?

> 3. Use an emulator like an XDS560. This will normally provide a TCLK
> of about 30 Mhz. The normal TCLK for low end emulators is 8-12 Mhz
> [this is configurable on some]. On large block reads performance
> improvements are almost directly proportional to the TCLK rate
> improvements. i.e., going from 8 Mhz to 12 Mhz TCLK will yield almost
> 50% improvement.

I'll stick to the embedded JTAG of DSK6713, the college i studying
does not has the emulator. Is RTDX a better choice for transferring
file of more than 1MB into SDRAM? My project purpose is to store a MP3
file into the DSK6713, then decode and play the music.

_____________________________________
Reply by Michael Dunn November 19, 20092009-11-19
Thx Jeff for clarifying - I've been busy and probably haven't followed
in enough detail.

To speed up fread()

1. Ensure that cache and SDRAM are setup correctly.
2. Use large blocks [one huge one, if possible]. CCS and the OS might
break them up behind the scenes, but we cannot do anything about that.
3. Use an emulator like an XDS560. This will normally provide a TCLK
of about 30 Mhz. The normal TCLK for low end emulators is 8-12 Mhz
[this is configurable on some]. On large block reads performance
improvements are almost directly proportional to the TCLK rate
improvements. i.e., going from 8 Mhz to 12 Mhz TCLK will yield almost
50% improvement.

mikedunn

On Thu, Nov 19, 2009 at 10:59 AM, Jeff Brower wrote:
> Mike-
>
>> There has been discussion about performance issues. In your case, the
>> number one issue is fread(). The secondary issues are JTAG clock rate
>> [emulator performance] and caching of SDRAM accesses.
>>
>> I have written many times on this list of the performance issues with
>> C library IO routines [printf, fread, clock/time, etc.]. The
>> simplified events for fread() are
>> [1] compiler inserts a breakpoint [with a special named label] and an
>> opcode at the point of an fread call
>> [2] the program runs to the breakpoint and halts
>> [3] CCS recognizes the the label
>> [4] CCS reads the opcode and fread parameters
>> [5] CCS performs the disk read
>> [6] CCS performs 6713 memory writes into the fread buffer.
>> [7] CCS issues a run command to the 6713
>>
>> This process can take a few milliseconds for a small amount of data -
>> you cannot use any of the stdio functions in realtime programs unless
>> your 'realtime' is very, very slow.
>
> My understanding is the OP (Chen Hui) is not after real-time operation, he just wants to read a file one time, inside
> main() and just that by itself was very slow. So he does only one fread() call. In that case, is there anything he
> can do to speed up?
>
> -Jeff
>
>> If you are just playing audio, I would suggest setting up the cache
>> for 64kB/4 way, putting your entire program [without wav data] and
>> stack in the remaining 192kB of internal memory. Make sure that the
>> LSB of the lower MAR registers is set to enable the caching of SDRAM.
>>
>> mikedunn
>>
>> On Wed, Nov 18, 2009 at 10:22 AM, Jeff Brower wrote:
>>>
>>>
>>>
>>> Chen Hui-
>>>
>>> >> First, if you are using a "low end" JTAG emulator (for example XDS510 PP or USB), and
>>> >> not RTDX, then fread() operations can take a long time. JTAG uses a relatively slow
>>> >> (10 to 20 MHz) one-line serial data transfer method.
>>> >
>>> > If I use RTDX through the DSK6713 ordinary JTAG Interface will the
>>> > speed become faster?
>>>
>>> Theoretically yes, but I think a lot depends on the emulator you are using. Some emulators just can't go fast, no
>>> matter what. What kind do you have?
>>>
>>> Some of the experts on this group, like Mike and Andrew and Richard, might have further comments about how to get
>>> the
>>> most out of RTDX and DSK 6713.
>>>
>>> >> Second, your read-from-file-write-to-SDRAM code is in main() and I don't see L2 cache
>>> >> setup code. If that's accurate then yes, SDRAM access could be slower than it should
>>> >> be. Suggest to look up the CACHE_xxx() functions in CSL and use these prior to
>>> >> accessing SDRAM.
>>> >
>>> > To cache the SDRAM, I need to include CACHE_enableCaching() before
>>> > starting the reading process ?
>>>
>>> Yes, but also some init and setup functions. For example, before enabling cache, you have to decide the amount of
>>> internal SRAM set aside for cache.
>>>
>>> > I have read in the DSK6713 document that SDRAM is mapped at the
>>> > beginning of EMIF CE0 (address 0x80000000). and must be configured in
>>> > software for proper operation. Some parameters are given:
>>> >
>>> > Parameter Value
>>> > CE0 Memory Type 32-bit wide SDRAM
>>> > Num. Banks 4
>>> > Num. Row Address Lines 12
>>> > Num. Column Address Lines 8
>>> > Refresh Period 1400
>>> >
>>> > But the tutorials given for DSK6713 does not teach how to configure
>>> > the EMIF. Anyone can help me in configuration the SDRAM? Examples and
>>> > documents will be helpful, thanks
>>>
>>> A good starting point is to look at EMIF register settings in the DSK 6713 .gel file. This file should be viewable
>>> after you open CCS (under GEL folder in lefthand window), or you can look for dsk6713.gel.
>>>
>>> Also this document (TMS320C6000 EMIF-to-External SDRAM Interface):
>>>
>>> http://focus.ti.com/lit/an/spra433e/spra433e.pdf
>>>
>>> -Jeff

--
www.dsprelated.com/blogs-1/nf/Mike_Dunn.php

_____________________________________
Reply by Jeff Brower November 19, 20092009-11-19
Mike-

> There has been discussion about performance issues. In your case, the
> number one issue is fread(). The secondary issues are JTAG clock rate
> [emulator performance] and caching of SDRAM accesses.
>
> I have written many times on this list of the performance issues with
> C library IO routines [printf, fread, clock/time, etc.]. The
> simplified events for fread() are
> [1] compiler inserts a breakpoint [with a special named label] and an
> opcode at the point of an fread call
> [2] the program runs to the breakpoint and halts
> [3] CCS recognizes the the label
> [4] CCS reads the opcode and fread parameters
> [5] CCS performs the disk read
> [6] CCS performs 6713 memory writes into the fread buffer.
> [7] CCS issues a run command to the 6713
>
> This process can take a few milliseconds for a small amount of data -
> you cannot use any of the stdio functions in realtime programs unless
> your 'realtime' is very, very slow.

My understanding is the OP (Chen Hui) is not after real-time operation, he just wants to read a file one time, inside
main() and just that by itself was very slow. So he does only one fread() call. In that case, is there anything he
can do to speed up?

-Jeff

> If you are just playing audio, I would suggest setting up the cache
> for 64kB/4 way, putting your entire program [without wav data] and
> stack in the remaining 192kB of internal memory. Make sure that the
> LSB of the lower MAR registers is set to enable the caching of SDRAM.
>
> mikedunn
>
> On Wed, Nov 18, 2009 at 10:22 AM, Jeff Brower wrote:
>>
>> Chen Hui-
>>
>> >> First, if you are using a "low end" JTAG emulator (for example XDS510 PP or USB), and
>> >> not RTDX, then fread() operations can take a long time. JTAG uses a relatively slow
>> >> (10 to 20 MHz) one-line serial data transfer method.
>> >
>> > If I use RTDX through the DSK6713 ordinary JTAG Interface will the
>> > speed become faster?
>>
>> Theoretically yes, but I think a lot depends on the emulator you are using. Some emulators just can't go fast, no
>> matter what. What kind do you have?
>>
>> Some of the experts on this group, like Mike and Andrew and Richard, might have further comments about how to get
>> the
>> most out of RTDX and DSK 6713.
>>
>> >> Second, your read-from-file-write-to-SDRAM code is in main() and I don't see L2 cache
>> >> setup code. If that's accurate then yes, SDRAM access could be slower than it should
>> >> be. Suggest to look up the CACHE_xxx() functions in CSL and use these prior to
>> >> accessing SDRAM.
>> >
>> > To cache the SDRAM, I need to include CACHE_enableCaching() before
>> > starting the reading process ?
>>
>> Yes, but also some init and setup functions. For example, before enabling cache, you have to decide the amount of
>> internal SRAM set aside for cache.
>>
>> > I have read in the DSK6713 document that SDRAM is mapped at the
>> > beginning of EMIF CE0 (address 0x80000000). and must be configured in
>> > software for proper operation. Some parameters are given:
>> >
>> > Parameter Value
>> > CE0 Memory Type 32-bit wide SDRAM
>> > Num. Banks 4
>> > Num. Row Address Lines 12
>> > Num. Column Address Lines 8
>> > Refresh Period 1400
>> >
>> > But the tutorials given for DSK6713 does not teach how to configure
>> > the EMIF. Anyone can help me in configuration the SDRAM? Examples and
>> > documents will be helpful, thanks
>>
>> A good starting point is to look at EMIF register settings in the DSK 6713 .gel file. This file should be viewable
>> after you open CCS (under GEL folder in lefthand window), or you can look for dsk6713.gel.
>>
>> Also this document (TMS320C6000 EMIF-to-External SDRAM Interface):
>>
>> http://focus.ti.com/lit/an/spra433e/spra433e.pdf
>>
>> -Jeff

_____________________________________
Reply by Michael Dunn November 19, 20092009-11-19
Hello Lim Chen Hui and others,


There has been discussion about performance issues. In your case, the
number one issue is fread(). The secondary issues are JTAG clock rate
[emulator performance] and caching of SDRAM accesses.

I have written many times on this list of the performance issues with
C library IO routines [printf, fread, clock/time, etc.]. The
simplified events for fread() are
[1] compiler inserts a breakpoint [with a special named label] and an
opcode at the point of an fread call
[2] the program runs to the breakpoint and halts
[3] CCS recognizes the the label
[4] CCS reads the opcode and fread parameters
[5] CCS performs the disk read
[6] CCS performs 6713 memory writes into the fread buffer.
[7] CCS issues a run command to the 6713

This process can take a few milliseconds for a small amount of data -
you cannot use any of the stdio functions in realtime programs unless
your 'realtime' is very, very slow.

If you are just playing audio, I would suggest setting up the cache
for 64kB/4 way, putting your entire program [without wav data] and
stack in the remaining 192kB of internal memory. Make sure that the
LSB of the lower MAR registers is set to enable the caching of SDRAM.

mikedunn

On Wed, Nov 18, 2009 at 10:22 AM, Jeff Brower wrote:
>
> Chen Hui-
>
> >> First, if you are using a "low end" JTAG emulator (for example XDS510 PP or USB), and
> >> not RTDX, then fread() operations can take a long time. JTAG uses a relatively slow
> >> (10 to 20 MHz) one-line serial data transfer method.
> >
> > If I use RTDX through the DSK6713 ordinary JTAG Interface will the
> > speed become faster?
>
> Theoretically yes, but I think a lot depends on the emulator you are using. Some emulators just can't go fast, no
> matter what. What kind do you have?
>
> Some of the experts on this group, like Mike and Andrew and Richard, might have further comments about how to get the
> most out of RTDX and DSK 6713.
>
> >> Second, your read-from-file-write-to-SDRAM code is in main() and I don't see L2 cache
> >> setup code. If that's accurate then yes, SDRAM access could be slower than it should
> >> be. Suggest to look up the CACHE_xxx() functions in CSL and use these prior to
> >> accessing SDRAM.
> >
> > To cache the SDRAM, I need to include CACHE_enableCaching() before
> > starting the reading process ?
>
> Yes, but also some init and setup functions. For example, before enabling cache, you have to decide the amount of
> internal SRAM set aside for cache.
>
> > I have read in the DSK6713 document that SDRAM is mapped at the
> > beginning of EMIF CE0 (address 0x80000000). and must be configured in
> > software for proper operation. Some parameters are given:
> >
> > Parameter Value
> > CE0 Memory Type 32-bit wide SDRAM
> > Num. Banks 4
> > Num. Row Address Lines 12
> > Num. Column Address Lines 8
> > Refresh Period 1400
> >
> > But the tutorials given for DSK6713 does not teach how to configure
> > the EMIF. Anyone can help me in configuration the SDRAM? Examples and
> > documents will be helpful, thanks
>
> A good starting point is to look at EMIF register settings in the DSK 6713 .gel file. This file should be viewable
> after you open CCS (under GEL folder in lefthand window), or you can look for dsk6713.gel.
>
> Also this document (TMS320C6000 EMIF-to-External SDRAM Interface):
>
> http://focus.ti.com/lit/an/spra433e/spra433e.pdf
>
> -Jeff
>
>
--
www.dsprelated.com/blogs-1/nf/Mike_Dunn.php

_____________________________________
Reply by Jeff Brower November 18, 20092009-11-18
Chen Hui-

>> First, if you are using a "low end" JTAG emulator (for example XDS510 PP or USB), and
>> not RTDX, then fread() operations can take a long time. JTAG uses a relatively slow
>> (10 to 20 MHz) one-line serial data transfer method.
>
> If I use RTDX through the DSK6713 ordinary JTAG Interface will the
> speed become faster?

Theoretically yes, but I think a lot depends on the emulator you are using. Some emulators just can't go fast, no
matter what. What kind do you have?

Some of the experts on this group, like Mike and Andrew and Richard, might have further comments about how to get the
most out of RTDX and DSK 6713.

>> Second, your read-from-file-write-to-SDRAM code is in main() and I don't see L2 cache
>> setup code. If that's accurate then yes, SDRAM access could be slower than it should
>> be. Suggest to look up the CACHE_xxx() functions in CSL and use these prior to
>> accessing SDRAM.
>
> To cache the SDRAM, I need to include CACHE_enableCaching() before
> starting the reading process ?

Yes, but also some init and setup functions. For example, before enabling cache, you have to decide the amount of
internal SRAM set aside for cache.

> I have read in the DSK6713 document that SDRAM is mapped at the
> beginning of EMIF CE0 (address 0x80000000). and must be configured in
> software for proper operation. Some parameters are given:
>
> Parameter Value
> CE0 Memory Type 32-bit wide SDRAM
> Num. Banks 4
> Num. Row Address Lines 12
> Num. Column Address Lines 8
> Refresh Period 1400
>
> But the tutorials given for DSK6713 does not teach how to configure
> the EMIF. Anyone can help me in configuration the SDRAM? Examples and
> documents will be helpful, thanks

A good starting point is to look at EMIF register settings in the DSK 6713 .gel file. This file should be viewable
after you open CCS (under GEL folder in lefthand window), or you can look for dsk6713.gel.

Also this document (TMS320C6000 EMIF-to-External SDRAM Interface):

http://focus.ti.com/lit/an/spra433e/spra433e.pdf

-Jeff

_____________________________________
Reply by lim chen hui November 18, 20092009-11-18
> First, if you are using a "low end" JTAG emulator (for example XDS510 PP or USB), and
> not RTDX, then fread() operations can take a long time. JTAG uses a relatively slow
> (10 to 20 MHz) one-line serial data transfer method.

If I use RTDX through the DSK6713 ordinary JTAG Interface will the
speed become faster?

> Second, your read-from-file-write-to-SDRAM code is in main() and I don't see L2 cache
> setup code. If that's accurate then yes, SDRAM access could be slower than it should
> be. Suggest to look up the CACHE_xxx() functions in CSL and use these prior to
> accessing SDRAM.

To cache the SDRAM, I need to include CACHE_enableCaching() before
starting the reading process ?
I have read in the DSK6713 document that SDRAM is mapped at the
beginning of EMIF CE0 (address 0x80000000). and must be configured in
software for proper operation. Some parameters are given:

Parameter Value
CE0 Memory Type 32-bit wide SDRAM
Num. Banks 4
Num. Row Address Lines 12
Num. Column Address Lines 8
Refresh Period 1400

But the tutorials given for DSK6713 does not teach how to configure
the EMIF. Anyone can help me in configuration the SDRAM? Examples and
documents will be helpful, thanks

_____________________________________
Reply by Jeff Brower November 17, 20092009-11-17
Chen Hui-

> Thanks, I've got it working now. I've set it to return error message
> when fread() returns zero. The error() is a custom function which i
> used to display message. I was trying both LOG_printf() and printf()
> function and found out that LOG_printf() doesnt update real time
> anymore when fread() is being use. Btw...the fread() is extreamly
> slow, it takes around 1 minute or more to read a 100kb file into SRAM.
> Is it normal?

First, if you are using a "low end" JTAG emulator (for example XDS510 PP or USB), and
not RTDX, then fread() operations can take a long time. JTAG uses a relatively slow
(10 to 20 MHz) one-line serial data transfer method.

Second, your read-from-file-write-to-SDRAM code is in main() and I don't see L2 cache
setup code. If that's accurate then yes, SDRAM access could be slower than it should
be. Suggest to look up the CACHE_xxx() functions in CSL and use these prior to
accessing SDRAM.

My guess is that in your case JTAG is the main thing causing slowness. If you want
to make separate measurements for JTAG vs. SDRAM, then try reading into onchip SRAM
(but read a reduced amount of data to fit an SRAM buffer).

-Jeff

> On Mon, Nov 16, 2009 at 2:48 AM, Richard Williams
> wrote:
> > limchenhui,
> >
> > If I understand your problem correctly...
> > the 'Opened Succesfully' error message was displayed.
> > BTW:
> > Rather than using 'error()', you might be better served to use:
> > fprint() followed (on an actual error) by 'exit()'
> >
> > According to my research, fread() returns the number of bytes read,
> > not a status value.
> >
> > you may also want to read ... to be aware of 'byte' sizing considerations:
> >
> > http://focus.ti.com/lit/an/spra757/spra757.pdf
> >
> >
> >
> >
> > perhaps if you were to code something similar to this example for a PC:
> > Note: the variable 'result' contains the number of bytes read, not a status
> > To determine if the fread() failed, compare the number of bytes read with
> > the number of bytes trying to be read.
> >
> > /* fread example: read a complete file */
> >
> > #include
> >
> > #include
> >
> >
> >
> > int main () {
> >
> > FILE * pFile;
> >
> > long lSize;
> >
> > char * buffer;
> >
> > size_t result;
> >
> >
> >
> > pFile = fopen ( "myfile.bin" , "rb" );
> >
> > if (pFile==NULL) {fputs ("File error",stderr); exit (1);}
> >
> >
> >
> > // obtain file size:
> >
> > fseek (pFile , 0 , SEEK_END);
> >
> > lSize = ftell (pFile);
> >
> > rewind (pFile);
> >
> >
> >
> > // allocate memory to contain the whole file:
> >
> > buffer = (char*) malloc (sizeof(char)*lSize);
> >
> > if (buffer == NULL) {fputs ("Memory error",stderr); exit (2);}
> >
> >
> >
> > // copy the file into the buffer:
> >
> > result = fread (buffer,1,lSize,pFile);
> >
> > if (result != lSize) {fputs ("Reading error",stderr); exit (3);}
> >
> >
> >
> > /* the whole file is now loaded in the memory buffer. */
> >
> >
> >
> > // terminate
> >
> > fclose (pFile);
> >
> > free (buffer);
> >
> > return 0;
> >
> > }
> >
> >
> > ---------- Original Message -----------
> > From: l...@gmail.com
> > To: c...
> > Sent: Sat, 14 Nov 2009 09:28:46 -0500
> > Subject: [c6x] fread into SDRAM
> >
> >>
> >>
> >> Hi guys,
> >>
> >> I'm using DSK6713 to read a data(WAV) file and produce the audio via
> >> aic23. The problem i facing is that the data file is too big to store in
> >> IRAM. I'm trying to read the file and store into the SDRAM but the fread()
> >> failed...can anyone teach me how to read file and stores into SDRAM?
> >>
> >> The portion of my code for storing in SDRAM is as below,
> >>
> >> Int16* ram;
> >>
> >> void main(){
> >> FILE *file;
> >>
> >> ram = MEM_alloc(SEG0, 102400, 0);
> >> if((file = fopen("testcase.dat","rb")) == NULL)
> >> error("Unable to open file");
> >> else error("Opened Succesfully");
> >> if(fread(&ram,100044,1,file) != 1)
> >> error("failed");
> >> }
> >>
> >> _SEG0 is the heap identifier header of SDRAM and segment for
> >> malloc()/free() has been set to SDRAM.

_____________________________________
Reply by lim chen hui November 17, 20092009-11-17
Thanks, I've got it working now. I've set it to return error message
when fread() returns zero. The error() is a custom function which i
used to display message. I was trying both LOG_printf() and printf()
function and found out that LOG_printf() doesnt update real time
anymore when fread() is being use. Btw...the fread() is extreamly
slow, it takes around 1 minute or more to read a 100kb file into SRAM.
Is it normal?

On Mon, Nov 16, 2009 at 2:48 AM, Richard Williams
wrote:
> limchenhui,
>
> If I understand your problem correctly...
> the 'Opened Succesfully' error message was displayed.
> BTW:
> Rather than using 'error()', you might be better served to use:
> fprint() followed (on an actual error) by 'exit()'
>
> According to my research, fread() returns the number of bytes read,
> not a status value.
>
> you may also want to read ... to be aware of 'byte' sizing considerations:
>
> http://focus.ti.com/lit/an/spra757/spra757.pdf
> perhaps if you were to code something similar to this example for a PC:
> Note: the variable 'result' contains the number of bytes read, not a status
> To determine if the fread() failed, compare the number of bytes read with
> the number of bytes trying to be read.
>
> /* fread example: read a complete file */
>
> #include #include int main () {
>
> FILE * pFile;
>
> long lSize;
>
> char * buffer;
>
> size_t result;
>
> pFile = fopen ( "myfile.bin" , "rb" );
>
> if (pFile==NULL) {fputs ("File error",stderr); exit (1);}
>
> // obtain file size:
>
> fseek (pFile , 0 , SEEK_END);
>
> lSize = ftell (pFile);
>
> rewind (pFile);
>
> // allocate memory to contain the whole file:
>
> buffer = (char*) malloc (sizeof(char)*lSize);
>
> if (buffer == NULL) {fputs ("Memory error",stderr); exit (2);}
>
> // copy the file into the buffer:
>
> result = fread (buffer,1,lSize,pFile);
>
> if (result != lSize) {fputs ("Reading error",stderr); exit (3);}
>
> /* the whole file is now loaded in the memory buffer. */
>
> // terminate
>
> fclose (pFile);
>
> free (buffer);
>
> return 0;
>
> }
> ---------- Original Message -----------
> From: l...@gmail.com
> To: c...
> Sent: Sat, 14 Nov 2009 09:28:46 -0500
> Subject: [c6x] fread into SDRAM
>
>> Hi guys,
>>
>> I'm using DSK6713 to read a data(WAV) file and produce the audio via
>> aic23. The problem i facing is that the data file is too big to store in
>> IRAM. I'm trying to read the file and store into the SDRAM but the fread()
>> failed...can anyone teach me how to read file and stores into SDRAM?
>>
>> The portion of my code for storing in SDRAM is as below,
>>
>> Int16* ram;
>>
>> void main(){
>> FILE *file;
>>
>> ram = MEM_alloc(SEG0, 102400, 0);
>> if((file = fopen("testcase.dat","rb")) == NULL)
>> error("Unable to open file");
>> else error("Opened Succesfully");
>> if(fread(&ram,100044,1,file) != 1)
>> error("failed");
>> }
>>
>> _SEG0 is the heap identifier header of SDRAM and segment for
>> malloc()/free() has been set to SDRAM.

_____________________________________
Reply by Richard Williams November 16, 20092009-11-16
limchenhui,

If I understand your problem correctly...
the 'Opened Succesfully' error message was displayed.
BTW:
Rather than using 'error()', you might be better served to use:
fprint() followed (on an actual error) by 'exit()'

According to my research, fread() returns the number of bytes read,
not a status value.

you may also want to read ... to be aware of 'byte' sizing considerations:
http://focus.ti.com/lit/an/spra757/spra757.pdf

perhaps if you were to code something similar to this example for a PC:
Note: the variable 'result' contains the number of bytes read, not a status
To determine if the fread() failed, compare the number of bytes read with the number of bytes trying to be read.
/* fread example: read a complete file */

#include

#include

int main () {

FILE * pFile;

long lSize;

char * buffer;

size_t result;

pFile = fopen ( "myfile.bin" , "rb" );

if (pFile==NULL) {fputs ("File error",stderr); exit (1);}

// obtain file size:

fseek (pFile , 0 , SEEK_END);

lSize = ftell (pFile);

rewind (pFile);

// allocate memory to contain the whole file:

buffer = (char*) malloc (sizeof(char)*lSize);

if (buffer == NULL) {fputs ("Memory error",stderr); exit (2);}

// copy the file into the buffer:

result = fread (buffer,1,lSize,pFile);

if (result != lSize) {fputs ("Reading error",stderr); exit (3);}

/* the whole file is now loaded in the memory buffer. */

// terminate

fclose (pFile);

free (buffer);

return 0;

}

---------- Original Message -----------
From: l...@gmail.com
To: c...
Sent: Sat, 14 Nov 2009 09:28:46 -0500
Subject: [c6x] fread into SDRAM

>
>
> Hi guys,
>
> I'm using DSK6713 to read a data(WAV) file and produce the audio via aic23. The problem i facing is that the data file is too big to store in IRAM. I'm trying to read the file and store into the SDRAM but the fread() failed...can anyone teach me how to read file and stores into SDRAM?
>
> The portion of my code for storing in SDRAM is as below,
>
> Int16* ram;
>
> void main(){
> FILE *file;
>
> ram = MEM_alloc(SEG0, 102400, 0);
> if((file = fopen("testcase.dat","rb")) == NULL)
> error("Unable to open file");
> else error("Opened Succesfully");
> if(fread(&ram,100044,1,file) != 1)
> error("failed");
> }
>
> _SEG0 is the heap identifier header of SDRAM and segment for malloc()/free() has been set to SDRAM.
Reply by limc...@gmail.com November 15, 20092009-11-15
Hi guys,

I'm using DSK6713 to read a data(WAV) file and produce the audio via aic23. The problem i facing is that the data file is too big to store in IRAM. I'm trying to read the file and store into the SDRAM but the fread() failed...can anyone teach me how to read file and stores into SDRAM?

The portion of my code for storing in SDRAM is as below,

Int16* ram;

void main(){
FILE *file;

ram = MEM_alloc(SEG0, 102400, 0);
if((file = fopen("testcase.dat","rb")) == NULL)
error("Unable to open file");
else error("Opened Succesfully");
if(fread(&ram,100044,1,file) != 1)
error("failed");
}

_SEG0 is the heap identifier header of SDRAM and segment for malloc()/free() has been set to SDRAM.

_____________________________________