Electronic – Need some help understanding PIC memory map

assemblyhi-tech-compilermemorymplabpic

Some background. I use MPLABx with a PicKit2 to program different types of pics. At the moment its the 16F887. I try to stick to the Hi-Tech PICC Lite tool chain but I'm growing increasingly unhappy with how some things are assembled. Operations which should be relativly fast (considering the 500ns instruction cycle at 8Mhz) are taking up to 20us to complete. So I've started inserting my own ASM code to deal with it.

However, I'm having difficulties understanding the memory map provided in the datasheet on Page 20.

Program memory starts at 0005h. However page 23 shows file addresses of special purpose registers, such as Port A for example. The address of Port A is shown as "05h".

I am confused how to differentiate between a memory location 0005h, and the special purpose register located at 05h. How do I reference the special purpose registers?

I've done pretty extensive assembler programming for older HC11 chips, but this is my first venture into PIC asm coding. Any help here would be appreciated.

Best Answer

The PIC uses what's called a "Harvard Architecture", which means that it has separate address spaces for instructions and data.

Whether an address refers to a register or an instruction depends on the context in which it is used.

The diagrams in section 2.1 "Program Memory Organization" are about program memory, or instruction address space. The diagrams in section 2.2 "Data Memory Organization" are about registers and special function registers, or data memory address space.