LCD and PIC18F4550


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Posts
    41


    Did you find this post helpful? Yes | No

    Smile Read-Modify-Write???

    Quote Originally Posted by Darrel Taylor View Post
    All you've done is treat the symptom.
    The problem is still there.
    And you've created some new problems in the process.

    Changing the LCD DEFINEs to LATA/B just overcomes the R-M-W (Read-Modify-Write) problem when ports are set to analog mode. It might seem like it's working fine, but it's not the right way to go.

    By doing that, the LCDOUT routines can't find the TRIS registers. Normally it finds TRIS by adding 12h to the Defined PORTx address. PORTA is F80h, if you add 12h, you get F92h which is the correct address for TRISA. But when you specify LATA (F89h), add 12h and you get F9Bh which is the OSCTUNE register.

    The only reason it worked is because you had already set all pins to output with the TRISA and TRISB assignments. (and you weren't using the internal oscillator)

    But, here's the good news.

    ADCON1 = $0F

    should fix it.

    Be sure to change the LCD DEFINEs back to PORTA/B

    Sir Darrel:
    I'm a bit confused,does it mean when I'm trying to read a Port configured as output in PIC16F877A, I will get the state of the Pin even if it's already an output, rather than the state of the Latch that switch that particular pin to output? is "LAT*" a work-around in PIC18F series?
    Last edited by leisryan; - 1st September 2008 at 11:02.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by leisryan View Post
    Sir Darrel:
    I'm a bit confused,does it mean when I'm trying to read a Port configured as output in PIC16F877A, I will get the state of the Pin even if it's already an output, rather than the state of the Latch that switch that particular pin to output? is "LAT*" a work-around in PIC18F series?
    Exactly!

    On 16F's, reading a pin in output mode reads the state of the pin itself, not the state you told it to output.

    Usually they are the same thing, unless there is capacitance on the pin that makes it change slowly. Or if the pin is in analog mode, the digital input is disabled and ALWAYS reads 0.

    On the 18F's, the LATx latches allow you to read the requested output state regardless of the actual state of the pin. This makes it easy to overcome the R-M-W problem found on the 16F's.
    <br>
    DT

Similar Threads

  1. DS18B20 and PIC18F4550
    By sjohansson in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 19th April 2006, 20:57
  2. Replies: 5
    Last Post: - 26th March 2006, 20:26

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts