o. Is Microchip PIC32 Flash Programming Specification faulty?

PIC32 Flash Programming Specification codenamed 61145G (page 25, table 14-1) states that assembly instruction “lui $s3, 0xFF20” translates to 32-bit code “3C04BF80”, which is according to MIPS32 documentation not true. The code “3C04BF80” means “lui $a0, 0xBF80”. The mistake is somehow corrected in the Flash Programming Specification codenamed 61145L (page 30, table 14-1), where the CPU instruction code for “lui $s3, 0xFF20” is correct, “3C13FF20”. However, this is insufficient, because the instruction loads only the upper 16-bits of $a0 register. The lower 16-bits may still contain a random number, if the register was used before. If you want the piece of code from the table 14-1 to work correctly regardless of the initial state of the CPU before programming, you should add the instruction “ori $s3,$s3,0” (code: “36730000”) immediately after the instruction “lui $s3, 0xFF20”. This sets the lower 16 bits of the s3 register to 0 and corrects the problem.

Not all programmers are equally capable of writing programs in the assembly language, which can be directly converted to CPU code language. There are many versions and revisions of Microchip PIC32 Flash Programming Specification with plenty of mistakes regarding CPU codes to be programmed into a PIC32 microcontroller with XferInstruction pseudo operation.

If you tend to implement your own PIC32 programmer, you would probably have to consider MIPS32 CPU documentation, first. Most of mistakes in the Microchip documentation are corrected in newer versions and revisions of the PIC32 Flash Programming Specification, but some may still remain.

Here is an example, but there are much more mistakes like this: