This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can't use float in sourcecode (uVision)

Hello,

i can't use float-Variables in my uVision programm.

If I only use integer-variables, the timer works without problems,as below.

#define STRINGBUF_LEN 21
char StringBuf[STRINGBUF_LEN];

void Timer_Callback (void const *arg) {

int adcVal[3];

adcVal[0] = ADC_GetValue();
sprintf(StringBuf, "%d", adcVal[0]);
GLCD_DrawString (0, 2*24, (char*)StringBuf);
}

But if I want to use a float-variable for example float x, the timer stops.

#define STRINGBUF_LEN 21
char StringBuf[STRINGBUF_LEN];

void Timer_Callback (void const *arg) {

int adcVal[3];
float x;

adcVal[0] = ADC_GetValue();
x = (adcVal[0] * 0.5) / 1024;
sprintf(StringBuf, "%d", adcVal[0]);
GLCD_DrawString (0, 2*24, (char*)StringBuf);
}