DSPRelated.com
Forums

byte accessing in memory and 16-bit word accessing through fread

Started by ahma...@yahoo.com June 10, 2008
Hi
Do you know in C55x dsps the following:
I use fread to read 16-bit samples from a file but even I use "2" as the size parameter for fread but it reads 8-bit samples for each execution of "fread" function. So How can I read a 16-bit samples by fread?

Also is it possible to set the arrange of memory in a manner that we could access it in byte or word(16-bit) samples.
Regards
Hi,
As far as i know, fread and fwrite functions always operate on 8-bitsamples only, if u are working on CCS .So after u read 8-bits , pack the successive 8-bits samples in to one 16-bit variable as shown below.
y[i] = x[i+1] << 2 | x[i]
where i represents the no. of bytes.
where x[i] containts 8 bit sample and y[i] contains 16-bit sample, which is your required output.
Hope, this will help you.

Regards,
sravanthi

On Tue, 10 Jun 2008 a...@yahoo.com wrote :
>Hi
>Do you know in C55x dsps the following:
>I use fread to read 16-bit samples from a file but even I use "2" as the size parameter for fread but it reads 8-bit samples for each execution of "fread" function. So How can I read a 16-bit samples by fread?
>
>Also is it possible to set the arrange of memory in a manner that we could access it in byte or word(16-bit) samples.
>Regards
>
SRAVANTHI