Searching \ for 'PCLATH and P16C74A ??' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/devices.htm?key=16C
Search entire site for: 'PCLATH and P16C74A ??'.

Truncated match.
PICList Thread
'PCLATH and P16C74A ??'
1998\03\08@223751 by Bob Smith x31105

picon face
Hello All,

Writing my first code for a PC16C74A - the data book indicates that
I need to take care of PCLATH<3> when using CALL or GOTO beyond the
2k boundary, and further states that I don't need to worry about it
on RETURN...  I've found that to be incorrect, at least when running
MPSIM...  is this an MPSIM bug?  or a mistake in the data book?

Thanks!

Bob

1998\03\08@231336 by Eric Smith

flavicon
face
Bob Smith x31105 <spam_OUTrsmithTakeThisOuTspamKODAK.COM> wrote:
> Writing my first code for a PC16C74A - the data book indicates that
> I need to take care of PCLATH<3> when using CALL or GOTO beyond the
> 2k boundary, and further states that I don't need to worry about it
> on RETURN...  I've found that to be incorrect, at least when running
> MPSIM...  is this an MPSIM bug?  or a mistake in the data book?

The note about RETURN simply means that the RETURN instruction is neither
affected by nor has any effect on the PCLATH register.  The RETURN instruction
will always return to the instruction following the call, regardless of the
PCLATH register contents.  If you change PCLATH before the call to the
subroutine, or during the subroutine, the RETURN instruction will not change
it back.

Ain't bank switching wonderful?

Cheers,
Eric

1998\03\08@233011 by Brian Schousek

picon face
Neither bug nor necessarily a mistake. Just a little incomplete. What the
book means is that the full 13 bits of the return address is included in the
stack, so your subroutine need not know from whence it was called. However,
once the subroutine has returned PCLATH is still set the way it was to
access the subroutine so if you do further work which is PCLATH dependent
you must set it to the current page after the subroutine is called.
The verbage in the data book which addresses this is: 'PCLATH is not
affected by a PUSH or POP operation.' (section 4.3.2 in my 1996 DS30390D
document, p. 41)

Brian
{Original Message removed}

1998\03\09@001942 by Calvin

flavicon
face
>Hello All,
>
>Writing my first code for a PC16C74A - the data book indicates that
>I need to take care of PCLATH<3> when using CALL or GOTO beyond the
>2k boundary, and further states that I don't need to worry about it
>on RETURN...  I've found that to be incorrect, at least when running
>MPSIM...  is this an MPSIM bug?  or a mistake in the data book?
>
>Thanks!
>
>Bob
>

Yeah!

I run into the same thing with a 16C63. After returning from the call or
goto the PCLATH register remained unchanged, so when another jump or branch
was found the thing would jump crazy.

I thought at first that I misunderstood the datasheet, but now I see that I
am not the only one. If they meant something different I think they
(Microchip) should clarify it.

Gabriel

1998\03\09@024218 by TONY NIXON 54964

flavicon
picon face
> I thought at first that I misunderstood the datasheet, but now I see that I
> am not the only one. If they meant something different I think they
> (Microchip) should clarify it.

In a multi page ROM environment like the 'C74 you should always set the
state of PCLATH<3> when addressing above or below the 2K boundary. It
is this bit that creates a 12 bit address from the 11 bit address supplied in a
GOTO/CALL instruction. If this bit = 0 you address under 2K. If
this bit = 1 then you address 2K and over.

Simple binary arithmetic.
If you have time, try it out with a calculator to clarify it.

PS. I think the data book is fairly intuitive on the subject. The
best way to clarify the principle of pages is to experiment with the
PCLATH with some simple GOTO/CALL code using a simulator.
It won't take long before the penny drops.

On the subject of data book content, it may be interesting to note, that
apart from some imagination, the whole PicNPoke range of software
came from the information supplied in the 16F(C)84 section from
Microchips' data book.

Regards

Tony

PicNPoke Multimedia 16F84 Beginners PIC Tools.

PicNPoke - PicNPlay - PicNPlan - PicNPrep - PicNPost
Plus DT type saver.
New addition - PicNPort I/O Tutor.

http://www.dontronics.com/picnpoke.html

1998\03\09@152532 by Harold Hallikainen

picon face
On Mon, 9 Mar 1998 16:58:02 +1000 TONY NIXON 54964
<.....Tony.nixonKILLspamspam@spam@ENG.MONASH.EDU.AU> writes:

>In a multi page ROM environment like the 'C74 you should always set
>the
>state of PCLATH<3> when addressing above or below the 2K boundary. It
>is this bit that creates a 12 bit address from the 11 bit address
>supplied in a
>GOTO/CALL instruction. If this bit = 0 you address under 2K. If
>this bit = 1 then you address 2K and over.


       And Microchip has defined a special instruction to handle this.
If you just say

       LCALL   MySubroutine


       MPASM will put in the appropriate BSF and BCF instructions on
PCLATH, then do a call.
       Easier than remembering which bit does what!  In adition, for
dealing with I/O and RAM, I've defined macros called bank0 and bank1.  I
don't have to remeber which bit handles that anymore either.

Harold


_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

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