|
发表于 2017-4-20 09:52:33
|
显示全部楼层
下面这个错误不知道你的代码能不能定位出来。就是当用SDRAM作为栈空间,函数返回时执行到pop{Rx,Ry,PC}指令,如果下面这种读取错误发生,就会将错误的值读取到PC,就会发生HardFault。这种HardFault发生有很大的不确定性,有时运行10个小时都不发生,有时运行10分钟就发,HardFault的种类也会有变化。若有多个任务,HardFault的位置可能有多个,代码上看不出任何问题,极难定位。
而且由于发生HardFault时,R0~R3,R12,LR,PC,XPSR,这8个寄存器会自动入栈,正好会把栈空间上发生读取错误的位置上的数据覆盖掉,就无法确认是否是栈上的数据真的错了。当然HardFault时入栈的PC值是个异常值,这是可以清楚看到的。
STM32F42xx and STM32F43xx silicon limitations
DocID023833 Rev 10
2.11.5 Interruption of CPU read burst access to an end of SDRAM row
Description:
If an interrupt occurs during an CPU AHB burst read access to an end of SDRAM row, it may result in wrong data read from the next row if all the conditions below are met:
• The SDRAM data bus is 16-bit or 8-bit wide. 32-bit SDRAM mode is not affected.
• RBURST bit is reset in the FMC_SDCR1 register (read FIFO disabled).
• An interrupt occurs while CPU is performing an AHB incrementing bursts read access of unspecified length (using LDM = Load Multiple instruction).
• The address of the burst operation includes the end of an SDRAM row.
Workaround:
Enable the read FIFO by setting the RBURST bit in the FMC_SDCR1 register. |
|