|
前言 这篇应用笔记描述了如何在AT32 MCU上使用FPU功能。 支持型号列表:具备FPU的型号 图1.程序中开启FPU.. 5 图2.Keil开启FPU.. 6 图3.Keil关闭FPU.. 7 图4.IAR开启FPU.. 8 图5.IAR关闭FPU.. 9 1 必要的代码准备1.1 程序中开启FPU打开system_at32f4xx.c文件,找到函数void SystemInit(void),确保内核有开启FPU功能,如图1黑斜体字部分。 注意:程序中开启FPU是必要条件。若仅开启Keil或IAR上的FPU,程序中未开启,则程序运行时会进入hardfault. 图1. 程序中开启FPU | void SystemInit (void) { #if defined (__FPU_USED) && (__FPU_USED == 1U) SCB->CPACR |= ((3U << 10U * 2U) | /* set cp10 full access */ (3U << 11U * 2U) ); /* set cp11 full access */ #endif /* reset the crm clock configuration to the default reset state(for debug purpose) */ /* set hicken bit */ CRM->ctrl_bit.hicken = TRUE; /* wait hick stable */ while(CRM->ctrl_bit.hickstbl != SET); /* hick used as system clock */ CRM->cfg_bit.sclksel = CRM_SCLK_HICK; /* wait sclk switch status */ while(CRM->cfg_bit.sclksts != CRM_SCLK_HICK); …………………………………………………………… …………………………………………………………… } |
2 Keil中配置FPU2.1 开启FPUOptions for Target->Target->Floating Point Hardware,选择Use Single Precision 2.2 关闭FPUOptions for Target->Target->Floating Point Hardware,选择Not Used 3 IAR中配置FPU3.1 开启FPUOptions ->General Options->FPU,选择VFPv4 singleprecision 3.2 关闭FPUOptions ->General Options->FPU,选择None
备注:本文档仅供有需求的伙伴们参考,如需更详细信息或操作步骤,请访问雅特力官网:https://www.arterytek.com/cn/support/index.jsp?index=1
|