Note that there are some explanatory texts on larger screens.

plurals
  1. POConvert a 32 bits to float value
    primarykey
    data
    text
    <p>I am working on a DSP processor to implement a BFSK frequency hopping mechanism using C on a Linux system. On the receiver part of the program, I am getting an input of a set of samples which I de-modulate using Goertzel algorithm to determine whether the received bit was a 0 or 1. </p> <p>Right now, I am able to detect the bits individually. But I have to return the data for processing in the form of a float array. So, I need to pack every set of 32 bits received to form a float value. Right I am doing something like :</p> <pre><code>uint32_t i,j,curBit,curBlk; unint32_t *outData; //this is intiallized to address of some pre-defined location in DSP memory float *output; for(i=0; i&lt;num_os_bits; i++) //Loop for number of data bits { //Demodulate the data and set curBit=0x0000 or 0x8000 curBlk=curBlk&gt;&gt;1; curBlk=curBlk|curBit; bitsCounter+=1; if(i!=0 &amp;&amp; (bitsCounter%32)==0) //32-bits processed, save the data in array { *(outData+j)=curBlk; j+=1; curBlk=0; } } output=(float *)outData; </code></pre> <p>Now, the values of the <code>output</code> array are just the values of <code>outData</code> array with 0s after the decimal point. example: if <code>output[i]=12345</code> the `outData[i]=12345.0000'.</p> <p>But while testing the program I am generating the sample test data of bits using an array of float <code>float data[] ={123.12456,45.789,297.0956};</code></p> <p>So after the demodulation I am expecting the float array <code>output</code> to have a same values as <code>data</code> array. Is there some other method to convert 32-bits of data to a float. Should I store the received bits to a <code>char</code> array and then convert it to float.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload