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
char garb_float[100]; float float_garb = 0.01f; snprintf(garb_float, 100, "%012.9f", float_garb);
The stack trace is
#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
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
Do you have a heap configured? As you are seeing, the printf-style functions can dynamically allocate memory, but only do so for some conversions.
That was the problem thanks, I found another sprintf implementation that did not require dynamic memory implementation, and that fixed it.