AnsweredAssumed Answered

Fixed Number encoded as a Float on SHARC

Question asked by jkolb on Aug 5, 2014
Latest reply on Aug 7, 2014 by jkolb


I’m having a issue with changing data types on the SHARC ADSP-21479.


I’m developing a program in C and I am receiving via a SPORT a fixed point 32-bit number that happens to already be in IEEE 754 format.


If I try to assign this number to a floating point variable, it will run the float assembly command and take the integer
equivalent of my received number and create a float equal to that number. Because my input number is already formatted for IEEE 754 single precision floating point it will give me an incorrect value.  Here is an example below to clarify:


     I receive a fixed point word of 0xA1235678


     This word is encoded as floating point so its value would be -5.534099E-19


     The processor believes it is an unsigned int from the SPORT that equals 2703447672.


     When i copy this number to a float it is taken that my input value is an int so my floating point variable gets the value 2.70345e+009.


     But the number I want would be the "true value" that is -5.534099E-19

I figure I may have to inline assembly code to do something like a "typeless" copy from memory location to location, or maybe there is a way to receive a word from the SPORT that the processor automatically thinks is a float?


Any suggestions on a better way to do this? Let me know if I'm thinking about this correctly or missing something obvious.


Thanks in advance,