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.

About MSP432.why does my program always jump into FaultISR()?

the code is one of the example from TI,named  fpu_simple_floating_point_operation.  When I press the button to trigger the interrupt for P1.1  ,the program sometimes jumped into the FaultISR(),but sometimes is normal.who can tell me why??

PS: do you think my English is very bad?

/* DriverLib Includes */
#include "driverlib.h"

/* Standard Includes */
#include <stdint.h>

#include <stdbool.h>
#include <math.h>

/* Statics */
static volatile bool flipFlop;

int main(void)
{
    volatile float fCalculate;
    uint32_t ii;
    flipFlop = false;

    MAP_WDT_A_holdTimer();

    /* Configuring P1.1 as an input and enabling interrupts */
    MAP_GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN1);
    MAP_GPIO_clearInterruptFlag(GPIO_PORT_P1, GPIO_PIN1);
    MAP_GPIO_enableInterrupt(GPIO_PORT_P1, GPIO_PIN1);
    MAP_Interrupt_enableInterrupt(INT_PORT1);
    MAP_Interrupt_enableMaster();

    while(1)
    {
        for(ii=0;ii<20;ii++)
        {
            fCalculate = (sin(50.5) * (12.2f / 50.1f) * 10.22f / 3) * ii;
        }
    }
}

/* GPIO ISR */
void gpio_isr(void)
{
    uint32_t status;

    status = MAP_GPIO_getEnabledInterruptStatus(GPIO_PORT_P1);
    MAP_GPIO_clearInterruptFlag(GPIO_PORT_P1, status);

    /* Toggling the output on the LED */
    if(status & GPIO_PIN1)
    {
        if(flipFlop)
        {
            MAP_FPU_disableModule();
            flipFlop = false;
        }
        else
        {
            MAP_FPU_enableModule();
            flipFlop = true;
        }
    }

}

  • What floating point option (--float_support) did you build this with?

    Supposing that MAP_FPU_disablemodule works like FPU_disableModule, it turns off the FPU; with the FPU turned off, any floating point instruction will get a UsageFault.

    On the other hand, if you built the program for software floating point, turning off the FPU presumably causes no trouble, but turning it on does no good.

  • In addition, there is no debounce on the switch input. So pressing the switch may invoke the ISR 1, 2, 3, or more times. So it's a crap shoot as to what value flip-flop has when you get back around to the floating point calculation.

    This may explain why it works sometimes and not others.
  • Perhaps not what you said...Because i just found that when the FPU is disable,the program can jump into interrupt normally.But when the FPU is able,if i press the button,the program will jump into gpio_isr() first,then it run into FaultISR()......For help~~
  • Hi user3907158,

    The runtime startup routine enables the FPU by default. That's why when you disable the FPU you end up in a fault handler when the first FPU instruction gets executed.

    The --float-support (Project properties -> Build -> ARM Compiler -> Processor Options) option is what tells the compiler what code to generate. By default it uses FPv4SPD16.

    Regards,

    David

**Attention** This is a public forum