srand issue causing Cpu_ivINT_Hard_Fault

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

srand issue causing Cpu_ivINT_Hard_Fault

775 Views
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.

Labels (1)
2 Replies

662 Views
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

662 Views
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 Kudos