本帖最后由 yyjccit 于 2013-4-16 14:15 编辑
我用的新华龙一块M3芯片,SIM3U146,debug时,还没进主函数了,在启动代码时就运行到HardFault_Handler死循环了。我单步运行步骤如下:
LDR R0, = SystemInit
BLX R0
-》
//------------------------------------------------------------------------------
void SystemInit(void)
{
// To disable the pin reset delay described below, make sure the preprocessor
// symbol si32HalOption_disable_pin_reset_delay is defined by your toolchain.
# if !defined(si32HalOption_disable_pin_reset_delay)
// If the reset pin was the source of the last reset, delay for 500 msec.
// Firmware can disable the debug port by inadvertantly setting the AHB
// clock source to a disabled clock. If this happens too quickly after a
// reset, it is not possible for a debug agent to gain control and thus
// not possible to reprogram the on-chip flash. Adding a delay here gives
// a debug agent sufficient time to connect.
if ((SI32_RSTSRC_0->RESETFLAG.PINRF == 1)
&& (SI32_RSTSRC_0->RESETFLAG.PORRF == 0)
&& (SI32_RSTSRC_0->RESETFLAG.VMONRF == 0))
{
// Set the SysTick timer to count down 10M ticks @ 20MHz (~500 msec)
SysTick->LOAD = 0xA00000;
SysTick->VAL = 0;
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;
// Wait for the count down to complete
while (0 == (SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk)) {}
// Set the SysTick timer to reset values
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
}
# endif
// invoke the application's system initialization.
mySystemInit();
}
if函数没有进去,进入
void mySystemInit()
{
// disable the watchdog timer to prevent device resets
// any lines added to this function should be added below this line of code
SI32_WDTIMER_A_stop_counter (SI32_WDTIMER_0);
}
然后就死在
void HardFault_Handler(void)
{
printf("HardFault_Handler\n");
/*NO SECOND LEVEL HANDLER SPECIFIED (halt USED)*/
halt();
}
请问这个问题可能由啥原因引起的?
|