srand issue causing Cpu_ivINT_Hard_Fault

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

srand issue causing Cpu_ivINT_Hard_Fault

1,518 次查看
richardw
Contributor I

When debugging, the very first time after compiling the code the debugger faults at Cpu_ivINT_Hard_Fault. If I reset the processor and run again, it doesn't happen.

Any ideas?

I am using the MK10DK128VLK7 and the Kinetis IDE.

In the debugger, I step through the code and it always faults at the srand line.

标签 (1)
标记 (3)
2 回复数

1,405 次查看
BlackNight
NXP Employee
NXP Employee

What debug connection/probe are you using? First I would check that the latest drivers are installed (e.g. P&E and Segger). If using P&E, you can update to the latest P&E software with Help > Install New software and select the P&E update site. For Segger see Updating Segger Tools in Eclipse Kinetis Design Studio | MCU on Eclipse .

Other than that: it could be some kind of stack overflow: make sure you have enough stack allocated.

Posting an example project of your problem would be helpful too.

I hope this helps,

Erich

1,405 次查看
richardwheatley
Contributor I

Took me forever to be able to log back in for some reason. Thank you for your comments.

There is definitely enough stack space as I have allocated 0x800 and monitoring the stack during usage, it never goes above 0x30E. Oddly enough, after adding that code, the issue never happened and hasn't happened since?

I will monitor this and post anything new in case it pops back up.

Quick question about the stack although I think I know the answer.

  • The stack works backwards, yes?
  • So if the stack goes up to 0x1FFFFFFF, then the maximum stack size should be monitoring the minimum value starting at 0x1FFFFFFF?

I used the following code to trace the stack: 

  • static inline uint32_t __get_MSP(void)

    {

        register uint32_t regMainStackPointer __ASM("sp");

        return(regMainStackPointer);

    }

0 项奖励
回复