Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What is the difference between LAT and PORT?

Status
Not open for further replies.

dellta

Newbie level 3
Joined
Feb 23, 2006
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,301
regarding PIC

can someody tell me what the different between LAT and PORT i confuse of this two. Thank
 

Re: regarding PIC

can someody tell me what the different between LAT and PORT i confuse of this two. Thank



The latch is the output latch onto which values are written. The port is the voltage at the actual pin.

There are a few situations where they can be different. The one that I've encountered most frequently is if you have a pin (accidentally) shorted to ground. If you set the latch high, the latch will read high, but the port will read low because the voltage on the pin is still approximately ground.

Another situation leading to what you've described is when the port pin hasn't been configured correctly. I (and everyone I work with) have spent many hours trying to figure out why our PIC isn't working to expectations, to eventually find out that we glossed over turning off the analog modules, for instance. Make sure you go over the section I/O Ports -> PORT?, TRIS?, and LAT? registers in the datasheet. See also this Microchip wiki page which explains about reading the wrong value immediately after you write an output on a pin connected to a capacitive load.

That wiki page also explains:

A read of the port latch register returns the settings of the output drivers, whilst a read of the port register returns the logic levels seen on the pins.

Also, here's a snippet from the I/O Ports section on the 18F14K50 (which ought to be the same as the rest of the 18F series):

Each port has three registers for its operation. These registers are:

TRIS register (data direction register)
PORT register (reads the levels on the pins of the device)
LAT register (output latch)
So in most situations, you will write to the latch and read from the port.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top