我用的是TM4C123GXL
我想问一下什么情况需要打开浮点运算?
有什么具体的作用?
为什么需要打开?
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.
分享一个使用浮点运算的例子吧。
打开浮点运算单元后可以用这个单元来计算浮点运算,减少CPU开销。
#include <stdint.h>
#include <stdbool.h>
#include <math.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/fpu.h"
#include "driverlib/sysctl.h"
#include "driverlib/rom.h"
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define SERIES_LENGTH 100
float gSeriesData[SERIES_LENGTH];
int32_t i32DataCount = 0;
int main(void)
{
float fRadians;
ROM_FPULazyStackingEnable();
ROM_FPUEnable();
ROM_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
fRadians = ((2 * M_PI) / SERIES_LENGTH);
while(i32DataCount < SERIES_LENGTH)
{
gSeriesData[i32DataCount] = sinf(fRadians * i32DataCount);
i32DataCount++;
}
while(1)
{
}
}