4.3.2.5 Are There Any SFRs Usage Considerations?

The dsPIC architecture defines various Special Function Registers that control hardware peripherals or other aspects of the machine. In general these SFRs are accessed like other C variables.

Some SFRs represent memory mapped versions of CPU registers that the compiler depends upon. These registers should not be written to by a C program as this could silently damage the operation of the application, especially at higher optimization levels. Registers that should be avoided include: the memory mapped copies of the working registers (WREG0, WREG1 and so on), parts of CORCON, ACCAx, and ACCBx.

Like luggage at an airport, many SFRs look alike. That is to say, there are subtle differences between some peripheral registers from device to device. When compiling code for a generic device, avoid referring to SFR registers.