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.
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.
**Attention** This is a public forum