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 ?

regards

david

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 ?

regards

david

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.

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.

regards

david

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.