当前位置:   article > 正文

stm32407定义浮点数后进入硬件错误_stm32f407访问flahs最后2k的字节时出现硬件错误中断

stm32f407访问flahs最后2k的字节时出现硬件错误中断

用的stm32f407芯片,定义了一个float型变量,总是进入硬件中断,按照正点原子的移植方法,修改函数也不行,从网上参考了许多方法,说是UCOS-III不支持FPU,按照说明修改了函数都不行,不经不行,而且程序完全不能运行了。
后来看到有人说要在启动文件中开启FPU,按照方法修改了启动文件的Reset_Handler函数后,可以正常运行了。可能是UCOS-III的版本不一样,其他地方都不用改,只修改启动文件就可以了

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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号