打印

stm32f407在UCOS下使用浮点函数开方进入HardFault

[复制链接]
241|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
小蘭|  楼主 | 2018-7-29 13:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
首先有设置使用FPU,然后加入了,__FPU_PRESENT=1,__FPU_USED =1,只要使用浮点函数就进入HardFault。
部分有关代码:
#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "lcd.h"
#include "key.h"  
#include "dma.h"
#include "adc.h"
#include "dac.h"
#include "PG.h"
#include "24cxx.h"
#include "rtc.h"
#include "timer.h"
#include "math.h"
#include "arm_math.h"
#include "includes.h"


//LED0任务
//设置任务优先级
#define LED0_TASK_PRIO                               7
//设置任务堆栈大小
#define LED0_STK_SIZE                                      512
//任务堆栈        
OS_STK LED0_TASK_STK[LED0_STK_SIZE];
//任务函数
void led0_task(void *pdata);


//LED0任务
void led0_task(void *pdata)
{                 
        u32 temp1;
        float32_t *temp;
        pdata=pdata;
        while(1)
        {
                arm_sqrt_f32(2,temp);//使用FPU计算2的平方根
                temp1=(u32)(*temp*1000);//浮点数强制转换为整数
                //temp1=__sqrtf(3.0f)*1000;
                LCD_ShowxNum(110,600,temp1,4,16,0X80);
                LED0=0;
                delay_ms(80);
                LED0=1;
                delay_ms(920);
        };
}



用arm_SIN_f32也一样,但是如果直接使用__sqrtf则能正常运行,不知道怎么搞的。麻烦大家帮我。

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

451

主题

463

帖子

1

粉丝