Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 735663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:30:58+00:00 2026-05-14T07:30:58+00:00

I already read the datasheet and google but I still don’t understand something. In

  • 0

I already read the datasheet and google but I still don’t understand something.

In my case, I set PIN RC6 of a PIC18F26K20 in INPUT mode:

TRISCbits.TRISC6 = 1;

Then I read the value with PORT and LATCH and I have different value!

v1 = LATCbits.LATC6;

 v2 = PORTCbits.RC6;

v1 gives me 0 where v2 gives 1.

Is it normal?
In which case we have to use PORT and in which case LATCH?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:30:58+00:00Added an answer on May 14, 2026 at 7:30 am

    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. You can get more info in the 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From what I've already read this appears to be impossible, but I wanted to
Following the discussions here on SO I already read several times the remark that
I have an XmlDocument that already exists and is read from a file. I
All articles I've read about localization of a WinForms application assume that I already
Already implemented performance boosters : - Get compatible image of GraphicsConfiguration to draw on
I already know how to: Load properties files into my Spring configuration using: <context:property-placeholder
I already know the obvious answer to this question: just download <insert favorite windows
As already discussed in Lua as a general-purpose scripting language? Lua currently probably isn't
I already know Java, Objective C, C#, and some Python. I want to be
I already have a deploy.rb that can deploy my app on my production server.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.