|
|
View previous topic :: View next topic |
Author |
Message |
Guest
|
stack on PIC |
Posted: Mon Mar 02, 2009 3:50 am |
|
|
I want to read the stack of 18F4620 in a Array.
Can anyone suggest a method how i can do it? |
|
|
Ttelmah Guest
|
|
Posted: Mon Mar 02, 2009 5:37 am |
|
|
On the 18 chips, this is relatively easy. On the 16 chips it is basically impossible.
There are three registers available, that hold the contents of the current 'top of stack'. There is also a register holding the stack pointer. You would have to read the contents of the three registers, copy the values from these into your array, then either decrement the STKPTR register, or issue a POP instruction, then access the next three bytes. Repeat until the stack is empty. Then write all the data _back_ (otherwise you have destroyed the stack....).
The registers are at FFD, E and F, and the pointer is at FFC.
You must disable interrupts while updating the stack.
Why do you want to do this?. There are reasons to access the stack. For instance, you can actually extend it by using your own software stack, but doing this, normally only involves accessing the top entry (which is why the processor has instructions to do this). Reading the whole stack, sounds like a 'hard' way to do just about anything...
Best Wishes |
|
|
Guest
|
|
Posted: Mon Mar 02, 2009 6:29 pm |
|
|
I am implementing context switch in a RTOS and required the stack to be copied |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|