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.

Weird behavior when passing floats to functions

Hello.

I'm currently working on software for a Stellaris/Tiva Launchpad BoosterPack I've made, and seem to be at a road block. For a few months now, I've been writing software for the Stellaris/Tiva Launchpad using arm-none-eabi-gcc as the compiler, and debugging using OpenOCD and GDB.

In the current software, the issue occurs on line 94 of motor.c. At this line, the HardFault handler is thrown.

Also, it seems that inside of GDB, I'm unable to run the command info float. I don't know whether that's a related issue or not, but I would definitely like to be able to view those registers as well.

All related software can be found here.

The PCB Files + Schematic can be found here.

System specs:

Arch Linux (x64), OpenOCD + GDB + Minicom (UART)
Stellaris Launchpad (Rev B) 

  • No idea why you getting a fault. Some comments. In main.c:main(), this loop:

            for(i=9; i>=0; i++)
            {
                setMotor(0, 0.1*i);
                SysCtlDelay(SysCtlClockGet() / 3 / 10);
            }

    Is the i+ intentional? Style would say i--. This loop will go from 9 to 127. Try breaking up the calc to see which operation it is complaining about. eg.

    float x;
    float y;
    unsigned long z;

    x  = duty;
    x *= 2.0;
    x -= 1.0;
    x  = fabs(x);
    y  = (float)SysCtlClockGet();
    y /= 10000;
    y *= x;
    z = (unsigned long)y;

  • I feel silly that I didn't just try that to begin with. Eventually got that to work, although I still can't seem to successfully execute _info float_ in GDB.