Del documento dspic30f family reference manual (70046e.pdf) Página 254 y siguientes:
11.2.2 PORT Registers
Data on an I/O pin is accessed via a PORTx register. A read of the PORTx register reads the
value of the I/O pin, while a write to the PORTx register writes the value to the port data latch.
Many instructions, such as BSET and BCLR instructions, are read-modify-write operations.
Therefore, a write to a port implies that the port pins are read, this value is modified, and then
written to the port data latch. Care should be taken when read-modify-write commands are used
on the PORTx registers and when some I/O pins associated with the port are configured as
inputs. If an I/O pin configured as an input is changed to an output at some later time, an unexpected
value may be output on the I/O pin. This effect occurs because the read-modify-write
instruction reads the instantaneous value on the input pin and loads that value into the port data
latch.
11.2.3 LAT Registers
The LATx register associated with an I/O pin eliminates the problems that could occur with
read-modify-write instructions. A read of the LATx register returns the values held in the port
output latches, instead of the values on the I/O pins. A read-modify-write operation on the LAT
register, associated with an I/O port, avoids the possibility of writing the input pin values into the
port latches. A write to the LATx register has the same effect as a write to the PORTx register.
The differences between the PORT and LAT registers can be summarized as follows:
• A write to the PORTx register writes the data value to the port latch.
• A write to the LATx register writes the data value to the port latch.
• A read of the PORTx register reads the data value on the I/O pin.
• A read of the LATx register reads the data value held in the port latch.
Any bit and its associated data and control registers that are not valid for a particular device will
be disabled. That means the corresponding LATx and TRISx registers, and the port pin, will read
as zeros
La diferencia fundamental está en que hay instrucciones que implican escritura que al actuar directamente sobre el registro del PORT realizan una lectura del estado del PORT que es transferida al LATCH, pudiendo darse entonces un estado contradictorio entre el estado del PORT y del LATCH, al cambiar posteriormente el TRIS del puerto puede producirse un estado indefinido del mismo. Por ello aconsejan solo "leer" el PORT, no escribir en él pero por el contrario "leer" y "escribir" alegremente el LATCH ya que éste no presenta los problemas del PORT.