R.J.Hamlett Guest
|
Re: how Can I read the stack of the pic16F877? |
Posted: Mon Jul 07, 2003 2:34 am |
|
|
:=how Can I read the stack of the pic16F877?
The basic answer would be that you don't...
As another poster has said, for debugging purposes, most tools, can allow you to see the stack contents. However the stack on these PICs, is not available to hold data from inside the program. If you look at the 'block diagram' of the chip, in it's data sheet, you will see, that the only interface 'path' to the stack, is shown as being to/from the program counter. The memory organisation diagram, shows the only interface instructions, as being call, return, retfie, and retlw. The hardware stack on the PIC, is only designed to hold program addresses for subroutine calls, rather than being available to hold values, using 'push/pop' type instructions, as is common on many other architectures.
Microchip, do have an application note, showing how to implement a software stack, if you require this type of functionality inside your code.
The latter 18 family chips, do allow a limited ability to access the hardware stack (with care...). The stack pointer itself, is available as a register, and the contents of the top register in the stack, are also available through other registers, potentially allowing the stack to be manipulated. Hence if you require this type of access, you would have to change to one of these chips.
Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515759 |
|