我用这个程序测试FPU效果,现在程序时一次加上FPU_enableModule(),一次不加,可是发现两次P1.0的LED闪烁的频率完全一样,好像FPU没有作用,为什么??
/* DriverLib Includes */ #include "driverlib.h" /* Standard Includes */ #include <stdint.h> #include <stdbool.h> #include <math.h> int main(void) { volatile float fCalculate; uint32_t ii; flipFlop = false;/* Stop Watchdog */MAP_WDT_A_holdTimer();MAP_GPIO_setAsOutputPin(GPIO_PORT_P1,GPIO_PIN0); // FPU_enableModule();while(1){GPIO_toggleOutputOnPin(GPIO_PORT_P1,GPIO_PIN0);for(ii=0;ii<20;ii++){ fCalculate = (sin(50.5) * (12.2f / 50.1f) * 10.22f / 3) * ii;}} }
gaoyang9992006:
/** -------------------------------------------*MSP432 DriverLib - v01_04_00_18* -------------------------------------------** --COPYRIGHT--,BSD,BSD* Copyright (c) 2015, Texas Instruments Incorporated* All rights reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions* are met:** *Redistributions of source code must retain the above copyright*notice, this list of conditions and the following disclaimer.** *Redistributions in binary form must reproduce the above copyright*notice, this list of conditions and the following disclaimer in the*documentation and/or other materials provided with the distribution.** *Neither the name of Texas Instruments Incorporated nor the names of*its contributors may be used to endorse or promote products derived*from this software without specific prior written permission.** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.* --/COPYRIGHT--*/ /******************************************************************************** MSP432 FPU - Simple FPU Operation** Description: In this barebone example, the FPU is enabled and the* effectiveness of the FPU with respect to floating point math is examined* versus having the FPU disabled. A perpetual while loop is set up that* continuously does floating point calculation. When the push button* attached to P6.7 is pressed, the FPU is enabled/disabled. This shows* the user the power consumption differences when having the FPU enabled* versus having the FPU disabled. Less cycle counts mean the user can enter a* low power mode quicker.**MSP432P401*------------------*/|\||*| ||*--|RST|*||*|P1.1|<--Toggle Switch*||*||** Author: Timothy Logan******************************************************************************/ /* 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;}}}
gaoyang9992006:
你另外一个添加关闭该模块功能试试看。
jiahe fan:
回复 gaoyang9992006:
TI的这个例程是有问题的,在编译器的设置中开启FPU的情况下,调用FPU_disbleModule()函数会产生一个错误,并且这个例程看不出开启FPU的效果。
具体请参考 https://e2e.ti.com/support/microcontrollers/msp430/f/166/p/413420/1470908