On 2011-06-01, at 10:34 AM, RussellMc wrote: > I was thinking of setting up the stack in a manner such that the > footprints of the original setup were still visible. > When you start you have the system under explicit control and can > produce stack writes of known content. > Subsequently it may be possible to perform some action which depends > on the stack having the original value. > Tasks which "run out the door" when popped may be able to be trapped > almost immediately by a timer interrupt. >=20 > If "the stack wraps silently, as noted, it may be possible to work it > down to "empty" and then pop again to "wrap silently" so you are at > the top of the stack and working down. Calls with original data in > would pop to locations which were known. When you got a pop that did > something different you'd know the original value had been > overwritten. You may have one chance in 2^stack_address_bits of > missing a corruption if popping single addresses. Unfortunately, for the PIC16f886, the only access to the stack happens with= the call, interrupt and return instructions. There is no other access. I t= hink the only option is to instrument round the instructions in ones own co= de. Since the OP was looking for a way to determine stack depth in use, overflo= w and underflow, this would satisfy the requirement in these restrictive ci= rcumstances. One could monitor these in a mirrored stack to look at where t= he faults are happening, which I where I think you are going with this Russ= ell. --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .