STM32
直播中

yqdedli

9年用户 984经验值
擅长:控制/MCU
私信 关注
[问答]

stm32cubeIDE移植的UCOSIII,定义float变量后进入硬件错误怎么解决?

如题:STM32cubeIDE移植的UCOSIII,STemwin,用的stm32407芯片,定义float变量后进入硬件错误
之前是Keil5移植的时候也遇到了这个问题,然后是在启动文件中加了一段代码解决了。
这次因为启动文件也不一样了,不知道改怎么修改。

回帖(2)

罗标雄

2024-4-12 14:51:32
启动文件cubeide里面有和MDK内容有区别。 
举报

李旭彤

2024-4-12 14:51:46
楼主需要修改一下.s文件,增加对硬件浮点计算的处理,错误中断是由于硬件浮点使用后,不能正确跳转回ucos系统导致。下面代码加到对应的startup_stm32f40xx.c中。位置就是上下;后面指定的位置。
; Reset handler
Reset_Handler   PROC
                EXPORT  Reset_Handler             [WEAK]
                IMPORT  SystemInit
                IMPORT  __main

                                LDR     R0, =SystemInit
                                BLX     R0
                                IF {FPU} != "SoftVFP"
                                                                                                ; Enable Floating Point Support at reset for FPU
                                LDR.W   R0, =0xE000ED88         ; Load address of CPACR register
                                LDR     R1, [R0]                ; Read value at CPACR
                                ORR     R1,  R1, #(0xF <<20)    ; Set bits 20-23 to enable CP10 and CP11 coprocessors
                                ; Write back the modified CPACR value
                                STR     R1, [R0]                ; Wait for store to complete
                                DSB

                                                                                                ; Disable automatic FP register content
                                                                                                ; Disable lazy context switch
                                LDR.W   R0, =0xE000EF34         ; Load address to FPCCR register
                                LDR     R1, [R0]
                                AND     R1,  R1, #(0x3FFFFFFF)  ; Clear the LSPEN and ASPEN bits
                                STR     R1, [R0]
                                ISB                             ; Reset pipeline now the FPU is enabled
                                ENDIF

                                LDR     R0, =__main
                                BX      R0
                                ENDP

; Dummy Exception Handlers (infinite loops which can be modified) 
举报

更多回帖

发帖
×
20
完善资料,
赚取积分