Searching \ for 'PIC Page Boundries' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'PIC Page Boundries'.

Truncated match.
PICList Thread
'PIC Page Boundries'
1999\02\02@171032 by Steven Kosmerchock

flavicon
face
Friends,
I am writing a program that is more than 2K. I am using
the PIC16C67 (8K) and have never had a program more than 2K.
The problem is that I assembled it in MPLAB and it says:

Crossing page boundary -- ensure page bits are set.

This is new to me. So how do I go about doing this? Do I set
the memory to bank1 where the code first indicates this message?
Any help would be greatly appreciated!! Thanks alot.

Best regards,
Steven



Steven Kosmerchock
Engineering Technician/Student
CELWAVE
Phoenix   Arizona   USA
Email:   spam_OUTsteve.kosmerchockTakeThisOuTspamcelwave.com
http://www.geocities.com/researchtriangle/lab/6584

1999\02\02@174353 by Tony Nixon

flavicon
picon face
Steven Kosmerchock wrote:
>
> Friends,
> I am writing a program that is more than 2K. I am using

It's quite easy to understand Page Boundaries.

GOTO and CALL instructions as with all others in this chip are 14 bits
wide. 3 are for the instruction, so it can only supply another 11 bits
for an address.

Binary 00000000000 - 11111111111 = 0 - 2047 or 2K ROM space.

In order to address more than this 2K instruction limit, there has to be
a mechanism available to add extra bits to the instruction. The
mechanism in the PIC is to use bits from the PCLATH register.

PCLATH bits <4:3> are used for this purpose and become the MSB's of the
GOTO/CALL instructions address. That way the total address becomes 13
bit, ie. able to address 8K of ROM.

If you do simple binary arithmetic on this you will see why it works.

PCLATH <4:3>  +  Instruction Address (00000000000 - 11111111111)
   0 0         0 - 2047     ROM Page 0
   0 1         2048 - 4095  ROM Page 1
   1 0         4096 - 6143  ROM Page 2
   1 1         6142 - 8191  ROM Page 3

It is upto you to determine the target address of your CALL GOTO
instructions. If this address is outside the 2K boundary limits as
mentioned above, then you will need to set the correct PCLATH bits
before the GOTO/CALL instruction.

You must keep track of all GOTO/CALL addresses throughout your program
when it spills over the 1st 2K boundary. If the PCLATH is not set
correctly then errors in your software will occur.

Try this in a simulator

     org 0h
     clrf PCLATH

     goto Page1
here  goto here      ; this is where you will stay.

     org 800h
     nop
     nop
Page1 goto Page1     ; the program will not get here.


If you bsf PCLATH,3 then the program will work as expected.

The PCLATH value does not change after a RETURN instruction, but the PC
will point to the instruction following the CALL. This is because the
stack holds the entire 13 bit address, so it can return from anywhere in
ROM.

--
Best regards

Tony

Multimedia 16F84 Beginners PIC Tools.
** NEW PicNPro Programmer and Port Interface **

http://www.picnpoke.com
Email .....picnpokeKILLspamspam@spam@cdi.com.au

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...