You may have a case of stack overflow. The real one, not the site :)
0x0530 is very low for your stack pointer. In the memory map for my device, its for peripherals.
Why it gets this value? I can only speculate.
- Do you initialize SP at start-up? Your compiler may do it for you. If you don't know, check in the debugger what the value of SP is before running (at program start). Run a couple of seconds, stop, and check again.
- Search for "stack" in the listing or map file generated at compile time. Can you find any information about the location and size of your stack?
- Do you have recursive functions?
- Are you declaring big local arrays in functions?
- Anything else that might be taking a lot of RAM?