2.3.1.1 Differences Between Execution of
SIX and a Normal Instruction
There are some differences between executing instructions normally and using the ICSP
SIX command. As a result, the code examples in this specification may not
match those for performing the same functions during normal device operation.
The important differences are:
- Two-word instructions require two
SIXoperations to clock in all of the necessary data.Examples of two-word instructions are
GOTOandCALL. - Two-cycle instructions require two
SIXoperations to complete.The first
SIXoperation shifts in the instruction and begins to execute it. A secondSIXoperation, which should shift in aNOPto avoid losing data, provides the CPU clocks required to finish executing the instruction.Examples of two-cycle instructions are Table Read (
TBLRD) and Table Write (TBLWT) instructions. - Must provide
NOPinstruction during Stall to account for pipeline changes.A CPU Stall occurs when an instruction modifies a register that is used for Indirect Addressing by the instruction immediately following the CPU Stall. During normal operation, the CPU will automatically force a
NOPwhile the new data are read. While using ICSP, the CPU stalls under the same conditions, but an instruction needs to be provided to generate the clocks to get through the Stall cycle. Therefore, any indirect references to a recently modified register should be preceded with aNOP.For example, the instructions
MOV#0x0,W0, followed byMOV[W0],W1, must have aNOPinserted in between.If a two-cycle instruction modifies a register that is used indirectly, it will require two following
NOPs: one to execute the second half of the instruction and the otherNOPstalls the CPU to correct the pipeline.For example, instructions such as
TBLWTL[W0++],[W1]should be followed by twoNOPs. - The device Program Counter (PC) continues
to automatically increment during ICSP instruction execution, even though the Flash memory
is not being used. As a result, the PC may be incremented so that it points to invalid
memory locations.
Examples of invalid memory spaces are unimplemented Flash addresses or the vector space (location: 0x0 to 0x1FF).
If the PC points to these locations, the device will reset, possibly interrupting the ICSP operation. To prevent this, instructions should be periodically executed to reset the PC to a safe space. The optimal method of achieving this is to perform a “
GOTO0x200” instruction.
