DSPRelated.com
Forums

Issue of fwrite() on C55x platform.

Started by LinL...@digital-control.com August 27, 2009
Hi,

I am working on C5510 DSK with CCS 3.3 and trying to read data from a file and write back data to another file.

It seems that fwrite() is not working well on this platform. The write out file is always empty. My code was working well on C54x platform.

Could anyone tell me the reason of that?

Thanks a lot,
Finspoo
Hi,
>
>I am working on C5510 DSK with CCS 3.3 and trying to read data from a file and write back data to another file.
>
>It seems that fwrite() is not working well on this platform. The write out file is always empty. My code was working well on C54x platform.
>
>Could anyone tell me the reason of that?
>
>Thanks a lot,
>Finspoo

I may have encountered the similar problem. I think fread() may not work well either. The run-time support library of C55x may not support fread() and fwrite() well.

My solution for fwrite() is:
1) split the variables of short (or int) type into bytes
2) write these bytes into file.

For example, the original code is:
fwrite(signal, sizeof(Word16), FRAME_SZ, fp);

The modified code is:
Word 8 signal_tmp[2*FRAME_SZ];
// Split into bytes
for (i=0; i {
signal_tmp[i+i] = (Word8)((singal[i] >> 8) & 0x0ff);
signal_tmp[i+i+1] = (Word8)(singal[i] & 0x0ff);
}
fwrite(signal_tmp, sizeof(Word8), 2*FRAME_SZ, fp);

FYI.

Best regards,
Thesee-

It sounds like byte-wide fread() and fwrite() work, but other widths do not. That would be odd, since C55x doesn't
actually have byte-addressable memory. It might be a C55x CSL software bug.

I suggest you report this on the TI E2E forum:

http://community.ti.com/

TI guys may already have a fix for it, and you could update your CCS.

-Jeff
>>I am working on C5510 DSK with CCS 3.3 and trying to read data from a file and write back data to another file.
>>
>>It seems that fwrite() is not working well on this platform. The write out file is always empty. My code was working
>> well on C54x platform.
>>
>>Could anyone tell me the reason of that?
>>
>>Thanks a lot,
>>Finspoo
>>
>> I may have encountered the similar problem. I think fread() may not work well either. The run-time support library of
> C55x may not support fread() and fwrite() well.
>
> My solution for fwrite() is:
> 1) split the variables of short (or int) type into bytes
> 2) write these bytes into file.
>
> For example, the original code is:
> fwrite(signal, sizeof(Word16), FRAME_SZ, fp);
>
> The modified code is:
> Word 8 signal_tmp[2*FRAME_SZ];
> // Split into bytes
> for (i=0; i > {
> signal_tmp[i+i] = (Word8)((singal[i] >> 8) & 0x0ff);
> signal_tmp[i+i+1] = (Word8)(singal[i] & 0x0ff);
> }
> fwrite(signal_tmp, sizeof(Word8), 2*FRAME_SZ, fp);
>
> FYI.
>
> Best regards,