Microcontroller › PIC › confusion in using latch register and port register › Hi,Avoid using statements
Avoid using statements like this in your ‘C’ code.
Take a temperory variable, say ‘t’ and convert the above statements like,
t = LATB;
LATB = ~t;
t = PORTA;
PORTA = ~t;
Port registers are connected to the port pin through Latch registers,
PORT REGISTER >> LATCH REGISTER >> PORT PIN
Even if you write a value to the port register, it will not appear at the port pin until you enable the latching using the lacth registers.
For a simple LED blinking, writing a ‘1’ or ‘0’ to port register (according to whether the anode or cathode of LED is connected to the pin) and then keep on enabling and disabling the latching will do the purpose.