tulan.kansagara wrote:Need to know in detail about LATx Register.
Writing to it is the same as writing to the corresponding PORTx register. Reading from it reads the last thing written, not necessarily what is read from the PORTx pins right now. The reason they could be different is if external circuit loading prevents the pin from achieving the state that was commanded. Also a pin that is configured as an input pin will obviously not follow what is written to the PORTx or the LATx register. The real benefit of having a LATx register as distinct from the PORTx register is when executing a Bit Clear or Bit Set instruction. The LATx register does what you expect. The PORTx register might not do what you expect. Setting or Clearing one bit might also change some other bit, but if you do that with the LATx register that does not happen. For more information look for info on the "Read-Modify-Write" problem in the old PICs that did not have the LATx registers.
P.S.: I'm glad Dario posted a link to this forum from the old broken official Microchip forum. Thanks Dario.