SECTION VI-6: The Program Counter and Program ROM Space in PIC

The role of the Program Counter (PC) in executing a program and show how the code is fetched from ROM and executed.

Program Counter PC is the important register in the PIC microcontroller. The program counter is used by the CPU to point to the address of the next instruction to be executed. As the CPU fetches the opcode from the program ROM, the program counter is incremented automatically to point to the next instruction. The wider the program counter, more the memory locations a CPU can access. A 14-bit program counter can access a maximum of 16K, 214 = 16K,  of code from address 0000 - 3FFFH. The PIC family 16F has 14-bit program counters. The program counter in PIC12F is 12-bit. In the case of a 16-bit program counter, the code space is 64K, 216 = 64K, which occupies the 0000 - FFFFH address range. The 8051 micro-controllers have a 16-bit program counter. 

The program counter in the PIC18 family is 21-bit. This means that the PIC18 can access program addresses 000000 to 1FFFFFH, a total of 2M of code. Not all members of the PIC family have the entire 2M, 221 = 2M, of on-chip ROM installed.

The 14-bit program counter in the PIC16C family had imposed the maximum code size of 16K. Yo overcome this major limitations, PIC designers had to introduce the jod of page switching in the later members of the PIC16 family. The solved the problem for the PIC18 family by expanding the program counter to 21-bit for that family.

The Program Counter in PIC18


More From