'Can someone help me understand memory pages?'
|I'm writing a program for the PIC16C57 and having some strange
Basically, I can't seem to write any code past address 200h
(IOW, I can't write more than 512 words of code) without the
program behaving very strangely. When my program is 511
words (last instruction at 1FFh), it works fine. Then when
I add a couple of NOPs anywhere in the program to push the
code over the 200h boundry (past the 512-word boundry), it
starts doing all sorts of odd things. Note that the program
does not crash, it just behaves strangely.
Anyway, I would expect this type of behavior from, say, a
PIC16C54 which has only 512-words of code space. But I'm
using a C57, which is supposed to have 2K.
After banging my head against the proverbial wall for a
while, I finally remembered that the PIC has 512 word pages.
So I was thinking that maybe there is something special you
have to do to move into another page. And the more I think
about it, the strange behavior I'm getting seems to be
similar to the type of behavior I would expect if the last
couple instruction words were getting cut out of my program.
So can someone help me: is there something special I need
to do after my code spills over onto a second page?
Thanks for any help. It will be greatly appreciated.
|On Thu, 28 Dec 95 02:01:07 GMT Mike Goelzer wrote:
> I'm writing a program for the PIC16C57 and having some strange
> Basically, I can't seem to write any code past address 200h
> (IOW, I can't write more than 512 words of code) without the
> program behaving very strangely.
--------- cut ------------
> So can someone help me: is there something special I need
> to do after my code spills over onto a second page?
> Thanks for any help. It will be greatly appreciated.
You shold set the page select bits in the status register before ussing
a "call" or "goto" to the code in the second code page The address in the
opcode is only 9 bit and the PIC uses the pages select bits to create
an 11 bit address.
The page select bits are set to '0' after reset. The program counter is 11
bits so the progrm can continue from address 1ffh to 200h and if you
have a "goto" from the code in the second code page it will go to the first
The stack is 11 bit wide so the "retlw" will return from the second code page
to the original page to the command after the "call" , but it will not change
the page select bits.
If you have a "goto" or "call" command from the first code page to the second
and did not set the code page bits the actual address will set the upper to
bits to '0' and will be in the middel of what ever you have in the first code
page. Just remember to set the code page bits to '0' after you return to the
code in the first page so any "goto" or "call" will no go to the second page.
| | Eyal Oppenheimer
| (o)(o) Aladdin Knowledge Systems Ltd.
C _) Tel: +972-3-537-5795
| ,___| Fax: +972-3-537-5796
| / E-mail: aladdin.co.ileyal
/____\ WWW: http://www.aks.com/
More... (looser matching)
- Last day of these posts
- In 1995
, 1996 only
- New search...