这篇应用笔记描述了如何在AT32 MCU上使用FPU功能支持型号 AT32F403xx AT32F403Axx AT32F407xx AT32F413xx

前言
这篇应用笔记描述了如何在AT32 MCU上使用FPU功能,支持型号列表:
支持型号列表:
支持型号
AT32F403xx
AT32F403Axx
AT32F407xx
AT32F413xx
目录
必要的代码准备… 5
程序中开启 FPU … 5
Keil 中配置 FPU … 6
开启 FPU… 6
关闭 FPU… 7
IAR 中配置 FPU… 8
开启 FPU… 8
关闭 FPU… 9
1、必要的代码准备
程序中开启 FPU打开system_at32f4xx.c文件,找到函数void SystemInit (void),确保内核有开启FPU功能,如图1黑斜
体字部分。
注意:程序中开启 FPU 是必要条件。若仅开启 Keil 或 IAR 上的 FPU,程序中未开启,则程序运行时会进入
hardfault.
图 1. 程序中开启 FPU
void SystemInit (void)
{
#if defined (AT32F415xx)
/* Enable low power mode, 0x40007050[bit2] */
RCC_APB1PeriphClockCmd(RCC_APB1PERIPH_PWR, ENABLE);
*(volatile uint8_t )(0x40007050) |= (uint8_t)(0x1 << 2);
RCC_APB1PeriphClockCmd(RCC_APB1PERIPH_PWR, DISABLE);
#endif
#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 RCC clock configuration to the default reset state(for debug purpose) /
/
Set HSIEN bit /
BIT_SET(RCC->CTRL, RCC_CTRL_HSIEN);
/
Reset SW, AHBPSC, APB1PSC, APB2PSC, ADCPSC and CLKOUT bits /
BIT_CLEAR(RCC->CFG, RCC_CFG_SYSCLKSEL | RCC_CFG_AHBPSC |
RCC_CFG_APB1PSC | RCC_CFG_APB2PSC |
RCC_CFG_ADCPSC | RCC_CFG_CLKOUT);

#ifdef VECT_TAB_SRAM
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /
Vector Table Relocation in Internal SRAM. /
#else
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /
Vector Table Relocation in Internal FLASH. */
#endif
}
2、Keil 中配置 FPU
开启 FPU
Options for Target->Target->Floating Point Hardware,选择Use Single Precision
图 2. Keil 开启 FPU
在这里插入图片描述
关闭 FPU
Options for Target->Target->Floating Point Hardware,选择Not Used
在这里插入图片描述
3、IAR 中配置 FPU
开启 FPU
Options ->General Options->FPU,选择VFPv4 single precision
在这里插入图片描述
关闭 FPU
Options ->General Options->FPU,选择None
图 5. IAR 关闭 FPU
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

章鱼哥嵌入式开发

坚持不易,你们的鼓励是我的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值