How do you convert a 24 bit fixed point output from an ADC to say 32 bit floating point in C and vice versa for a 24 bit dac ??
Is there a type casting in C or casting operator in C++ that automatically does this ?
The header file fract2float_conv.h contains functions that convert floating point to fixed point fract16 and fract32 and vice versa.
Note that all fracts are converted to floating point numbers between -1.0 and 1.0.
Would I need to normalize fixed point values to 32 bits ? ie for a 24 bit ADC shift left 8 bits to get 32 bits ?
I guess it depends on how much precision you need. If you do the shift, you get values between -1.0 and +1.0. If you don't do the shift then you get numbers between -0.00390625 and +0.00390625 (I think I did the math right, but it is Monday morning). You could then normalize the values in floating point. However, it is more efficient to do a logical shift rather than an floating point multiplication.
I was looking for fract2float_conv.h in the include directory (Visual DSP 5.0\212xx\include) and it doesn't appear to be there but I did find it in the Blackfin include directory. Must be different for the sharc.
Sorry, I assumed you were using the Blackfin. I have never compiled for the Sharc before. If there is no support for fract32 and fract16, I am not sure how to do the conversion from fixed to floating point, other than casting the 24-bit value to floating point and dividing by the the maximum fixed point value (i.e., (float) 0x00800000 which is 2^23). You have to manually handle the sign to do this properly.
Or maybe just cast it to a floating point and not worry about it because another divide would steal a fair few cycles. As long as all filter coefficients have been normalized then I can't see their being any problem with saturation of the multiplies. You'd have to make sure that you don't saturate the dac on the conversion back to fixed point.
Retrieving data ...