Tool/software: Code Composer Studio
Hi,
I am trying to convert the values I read from the F28335 12-bit ADC into float data type. I am using the following statement:
for(i=0; i < 10; i++) { OutBuff[i] = ( ( ( (float) *ADC_Buffer ) / 4096 ) * 3.0 ) - 1.5; // convert ADC data into volts and remove DC offset ADC_Buffer++; }
Actually, the ADC values are in an array and I am using pointers to access that array, hence the ' *ADC_Buffer'. I divide the values by 2^12 and multiply by 3.0 V to convert into voltage. Then I remove the 1.5 V DC offset which I provided externally to the signal.
Five values are listed below as an example:
ADC (decimal) | (Expected output) | Code Output |
1522 | -0.385253906 | 46.125 |
1812 | -0.172851563 | -1.5 |
2177 | 0.094482422 | -1.5 |
2488 | 0.322265625 | 34.5 |
2472 | 0.310546875 | 46.3125 |
Am I type-casting the values correctly or is there some mistake?
Regards,