输出堆栈信息

This commit is contained in:
nnhy 2014-08-17 20:15:16 +00:00
parent 88ef493e48
commit d4da8d7859
3 changed files with 20 additions and 5 deletions

View File

@ -211,7 +211,7 @@ void FAULT_SubHandler()
int i;
if(exception==3)
{
uint n = *(uint*)(0xE000ED2C);
uint n = *(uint*)(SCB_BASE + 0x2C);
debug_printf("\r\n硬件错误 %d\r\n", n);
if(n & (1<<1))
{
@ -228,7 +228,7 @@ void FAULT_SubHandler()
}
else if(exception==5)
{
i = *(byte*)(0xE000ED29);
i = *(byte*)(SCB_BASE + 0x29);
#ifdef STM32F10X
debug_printf("\r\nBus Fault %d 0x%08x: \r\n", i, SCB->BFAR);
#endif
@ -260,7 +260,7 @@ void FAULT_SubHandler()
}
else if(exception==4)
{
i = *(byte*)(0xE000ED28);
i = *(byte*)(SCB_BASE + 0x28);
#ifdef STM32F10X
debug_printf("\r\nMemManage Fault %d 0x%08x: \r\n", i, SCB->MMFAR);
#endif
@ -288,7 +288,7 @@ void FAULT_SubHandler()
}
else if(exception==6)
{
i = *(byte*)(0xE000ED2A);
i = *(byte*)(SCB_BASE + 0x2A);
debug_printf("\r\nUsage Fault %d: \r\n", i);
if(i & (1<<0))
{

16
Sys.cpp
View File

@ -6,6 +6,9 @@
TSys Sys;
TTime Time;
extern uint __heap_base;
extern uint __heap_limit;
#ifndef BIT
#define BIT(x) (1 << (x))
#endif
@ -258,7 +261,10 @@ TSys::TSys()
_Index = 0;
FlashSize = *(__IO ushort *)(0x1FFFF7E0); // 容量
if(FlashSize == 0xFFFF)
FlashSize = RAMSize = 0;
{
FlashSize = MemSizes[0];
RAMSize = RamSizes[0];
}
else
{
RAMSize = FlashSize >> 3; // 通过Flash大小和MCUID识别型号后得知内存大小
@ -398,6 +404,14 @@ void TSys::ShowInfo()
#endif
debug_printf("\r\n");
// 输出堆信息
uint start = (uint)&__heap_base;
uint end = (uint)&__heap_limit;
debug_printf("Heap :(0x%08x, 0x%08x) = 0x%x\r\n", start, end, end - start);
start = end;
end = 0x20000000 + (RAMSize << 10);
debug_printf("Stack:(0x%08x, 0x%08x) = 0x%x\r\n", start, end, end - start);
debug_printf("\r\n");
#endif
}

1
Sys.h
View File

@ -2,6 +2,7 @@
#define _Sys_H_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "stm32.h"