PCLATH = (program counter latch high) = the latch register you write to that
holds the value to be loaded into PCH.
PCH is the high 5-bits of the 13-bit program counter for the 14-bit core. PCL
is the lower 8-bits.
You can't write directly to PCH, so you write to PCLATH. The value you place
in PCLATH gets latched into the program counter high (PCH) when PCL is
written.
All 13-bits of the program counter have to be written simultaneously. That's
the purpose of the PCLATH latch register.
The error you're getting is because you haven't reserved enough space in the
beginning or program memory for the Tiny loader to automatically insert the
CLRF PCLATH instruction.
On return from the loader sub routine PCH needs to be cleared to point to the
program memory in bank 0 where your code is located.
If CLRF PCLATH can't be inserted before GOTO Main, then it would jump back
to program memory in bank 1 instead of bank 0 causing major problems.
As Steve mentioned, inserting DEFINE LOADER_USED 1 takes care of this since
it tells PBP to reserve the first 4 locations for loader use.
Bookmarks