We're working on a project where we have a set of 24-bit bipolar ADC reads the MCU needs to convert to floats.
There's a SWI that I had written that is too slow for the speed we need. While the SWI itself contains plentiful opportunities for optimization, for the purpose of this post however, I'd like to focus on speeding up the float conversion:
void fUInt24_to_float(float *dest, Uint32 *src, Uint32 length){ register int32 iTemp; register float fTemp; register int32 twoTo23= (1<<23);//TWOto23RD; register int32 twoTo24= (1<<24);//TWOto24TH; while(length){ iTemp=*src; if(iTemp & twoTo23){ iTemp-=twoTo24; } fTemp=iTemp; fTemp/=(float)twoTo23; *dest=fTemp; dest++;src++;length--; } }
Any suggestions like IEEE 754 ninja bit-math would be greatly appreciated.