Academic Program

Program Counter Control

Program Counter Control

In order to read or modify the 14-bit Program Counter with an 8-bit MCU two SFRs are utilized:

  • PCL: Contains the lower 8 bits of the program counter <PC7:0>.
  • PCLATH: Contents depends upon MCU operation being performed.

PCL and PCLATH are used when the program writes to the program counter, reads the program counter, or executes a GOTO or CALL instruction.

 

Writing to the Program Counter

When the application writes to PCL the current contents of PCLATH<5:0> will be written to PC<14:8>. Because of this, the contents of PCLATH<5:0> MUST always be correct BEFORE writing to PCL.

pcl-write.png

 

Reading the Program Counter

When PCL is read by an application PC<14:8> is captured into PCLATH.

pcl-read.png