This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMDSCNCD28379D: Using Printf with float numbers

Part Number: TMDSCNCD28379D
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hi,

I'm trying to send an ADC reading to UART terminal. Sending the value as integer (register value) works fine but when I try to send the converted value, which is float, I run into an exception:

Working:

sprintf(msg, "\r\n%s = %d [V]" , "Voltage = ", ADC_readResult(Vbat_BASE, ADC_SOC_NUMBER0)) ;

Not working:

float       vBat ;

vBat = ( ADC_readResult(Vbat_BASE, ADC_SOC_NUMBER0) )*( 0.1871F ) ;

sprintf(msg, "\r\n%s = %g [V]" , "Voltage = ", vBat) ;

Here's the screen shot of where the exception happens:

which shows this is the step where vBat is converted to string using %g

Here's a screen shot of the exception which I don't understand:

Any help is much appreciated.