Is there any idicator bit of Stack overflow in PSoC3. Seems like the program execution is random on attach to running target.
Busting the stack on a 8051 core as in a PSoC3 is an easy thing because it is so small. You can pre-load the stack with some defined values at start of main() and check after some time of running with the debugger if the stack is approaching to its limit.
Have a look at any warnings and take care when using pointers to functions which may lead to errors in PSoC3 environment when not explicitely cared for, they may produce random errors.
Keep an eye on heap usage as well.
In Creator you can set a watchpoint at the top of stack which will interrupt your program when that location is accessed.
A couple of interesting references -
But where this small stack is?
Is it here:
?STACK SEGMENT IDATA
XBPSTACK EQU 1
XBPSTACKTOP EQU CYDEV_SRAM_SIZE - 3 ;Keep in mind additional variables declared above
all is taken from KeilStart.a51
This might tangentially be of some help -