平台:TM4C123 launchpad
编译工具: IAR7.1
在starpup .c 启动文件里程序段如下
sta
tic void App_Reset_ISR (void)
[
//
// Enable the floating-point unit. This must be done here to handle the
// case where main() uses floating-point and the function prologue saves
// floating-point registers (which will fault if floating-point is not
// enabled). Any configuration of the floating-point unit using DriverLib
// APIs must be done here prior to the floating-point unit being enabled.
//
// Note that this does not use DriverLib since it might not be included in
// this project.
//
HWREG(NVIC_CPAC) = ((HWREG(NVIC_CPAC) &
~(NVIC_CPAC_CP10_M | NVIC_CPAC_CP11_M)) |
NVIC_CPAC_CP10_FULL | NVIC_CPAC_CP11_FULL);
__iar_program_start();
]
在主程序段里
void main(void)
[
FPUEnable();
FPULazyStackingEnable();
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
SYSCTL_OSC_MAIN);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
add_float();
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
GPIOPinConfigure(GPIO_PA0_U0RX);
GPIOPinConfigure(GPIO_PA1_U0TX);
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
UARTClockSourceSet(UART0_BASE, UART_CLOCK_PIOSC);
UARTStdioConfig(0, 115200, 16000000);
UARTprintf("test ");
]
void add_float(void)
[
float a = 4.47;
float b = 3.21;
float c;
c = a + b;
]
程序运行结果如下:
1. 如果把浮点运算函数 add_float() 注释掉 程序可以顺利运行打印出 test
2. 如果把浮点运算函数 add_float() 也运行, 程序就死在这个函数里 无法运行下去
请求达人指点一下, TM4C123不是支持浮点运算的吗?难道是编译器或者还有哪里没设置对?
不胜感激!