Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

CCS: Conversion from float to unsigned interger-16

$
0
0

Tool/software: Code Composer Studio

As, I am working CCS V_8 version and deveolping code for MSP432P401R. I am facing a strange problem regarding overflow. As I have my project chain (ADC-DSP-DAC) in my complete project, I am working to implement a digital bandpass filter on MSP432 of the order of 46th by using floating point feature of controller. ADC input range is (0-2.5V) and I am expecting output range same for DAC but the problem is that when I increased input value more than 2.38V Then it leads to an overflow issue. By changing offset vale on signal generator, this issue can be tackeld up to some limit but it is not a professional solution. By googling, i read some articles regarding data type conversions and followed the given procedure (i.e. int (float+0.5)) but it is not helping me. As, my question is more about c programming but I think It has relation with CCS also.

Overflow is occuring due to last values of output when some values are becoming less than zero.Can you please help me to eliminate this overflow issue ??

Note: I have attached the pictures of output  with overflow and without overflow alongside the specific part of code too. Every possible suggestion is highly appreciated.

This two picture are taking at the input of step response to the filter.

AdcInputVoltage = AdcValueDigits*2.5f/16384.0f;
     filteredf_output = SincFilter(AdcInputVoltage);
    /* if (filteredf_output<0){ DacValueDigits = (uint16_t)(( filteredf_output* 65536.0f/4.096f)+0.5);
     }
     else {DacValueDigits= (uint16_t)(( filteredf_output* 65536.0f/4.096f));
    } */
     DacValueDigits = (uint16_t)(( filteredf_output* 65536.0f/4.096f)+.5);
     //DacValueDigits = ((uint16_t)(( filteredf_output* 65536.0f/4.096f)+32678.5))-32677;

Regards,

Hasan Nawaz


Viewing all articles
Browse latest Browse all 262198


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>