Hi everyone,
What I'm trying to do is get an infrared decoding library (IRMP) to run, along with a simple HD47780 LCD display on a Stellaris Launchpad. The IRMP library basically polls the state of an IR receiver every time a timer interrupt fires.
Both libraries work fine by themselves. However, as soon as I execute only a single floating point operation in my main function (or any function called from it), the IRMP signal decoding breaks. So the IRMP code still runs, it still sends debugging data over the UART, still toggles LEDs, etc, but it's unable to correctly decode any input.
In my main function, all I have is a busy loop, checking if the IRMP library has successfully decoded something. I can break the code by executing an FPU operation even before initializing the IRMP library. The very first lines in my main are:
MAP_FPULazyStackingEnable();
MAP_FPUEnable();
An example of a line of code that breaks it all is:
MAP_SysCtlDelay((MAP_SysCtlClockGet()) / 30.0)
Change 30.0 to 30 and everything magically works again.
I've tried removing the MAP_ (or simply not sourcing driverlib/rom.h) to ensure the new StellarisWare driver library gets used instead of the one flashed into the LM4F120, but that didn't fix anything either.
This gets even stranger: if I compile with -O0, the decoding doesn't work either, however with -O1 or -Os (didn't try O2 and O3) it does (provided of course no FPU operations are executed from the main function).
The compiler I'm using is:
arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.7.3 20121207 (release) [ARM/embedded-4_7-branch revision 194305]
Compile flags:
-DPART_LM4F120H5QR -DARM_MATH_CM4 -DTARGET_IS_BLIZZARD_RA1 -I$SOMEDIR/stellarisware -Os -Wall -std=gnu99 -c
-fmessage-length=0 -fsingle-precision-constant -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mthumb -mfloat-abi=softfp
-ffunction-sections -fdata-sections
Compiling with -mfloat-abi=hard doens't work either.
As for linking and startup code, I'm using the one from https://github.com/scompo/stellaris-launchpad-template-gcc.
Do you have any idea on how to solve/fix this? Apart from me wading through all the IRMP code and changing all FP math to integer math. I realize FP math in an ISR is far from ideal, but that's not the point here. It should work and it isn't.
I've spend over 8 hours trying various things, searching all over the net and haven't found anything so far that could explain this behavior. I've also put this question on the IRMP forum and StackExchange Electronics.