CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

stack on PIC

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








stack on PIC
PostPosted: Mon Mar 02, 2009 3:50 am     Reply with quote

I want to read the stack of 18F4620 in a Array.
Can anyone suggest a method how i can do it?
Ttelmah
Guest







PostPosted: Mon Mar 02, 2009 5:37 am     Reply with quote

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








PostPosted: Mon Mar 02, 2009 6:29 pm     Reply with quote

I am implementing context switch in a RTOS and required the stack to be copied
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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