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

Sprintf hardfaulting with float input

Hello,

I'm using the arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-eabi for a cortex M4 on a TM4C1294NCPDT. I've run into a problem where the chip hard faults when a float is passed to sprintf. sprintf works with other inputs. The code to reproduce this is 

Fullscreen
1
2
3
char garb_float[100];
float float_garb = 0.01f;
snprintf(garb_float, 100, "%012.9f", float_garb);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The stack trace is 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
#0 FaultISR () at startup_gcc.c:293
#1 <signal handler called>
#2 0x00055084 in _malloc_r ()
#3 0x00056550 in _calloc_r ()
#4 0x00055a1a in _Balloc ()
#5 0x000562a8 in __d2b ()
#6 0x000567a2 in _dtoa_r ()
#7 0x00052fe4 in _svfprintf_r ()
#8 0x000579f4 in snprintf ()
#9 0x00031dd2 in main_MainLoop () at main.c:110
#10 0x000320da in ResetISR () at startup_gcc.c:262
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I'm also using the TI libraries for initialization if that helps. Does this toolchain have a function for converting strings to floats? Thank you for any guidance 

0