[SOLVED !] Reading data from a LCD display ?


Closed Thread
Results 1 to 3 of 3

Thread: Reading data from a LCD display ?2457 days old

  1. #1
    Cruster
    Guest Cruster's Avatar

    1 Not allowed!

    Default Reading data from a LCD display ?

    Has anyone attempted to read DDRAM data from a HD44780 controller based LCD display? i.e not the busy flag or the address counter but the actual data on the display?

    The problem I am having is that nothing is being returned from the display when I attempt the read. I can quite happily write to the display, but it would appear, not read data from it.

    To read data, I first set the DDRAM address to zero (the first location on the display) and then according to the data sheet. -

    1) Set RS and R/W both high
    2) wait a minimum of 40nS
    3) set E (enable) high
    4) wait a minimum of 120nS
    5) read the data (MSB nibble)
    6) wait a minimum of 230nS
    7) set E (enable) low
    8) wait a minimum of (500 - 230 - 120 - 40) = 110nS

    before repeating from step 3) for the LSB nibble as I am using 4 bit mode.

    The timings are from the data sheet I have for this LCD (a 4 x 40 display) and are the minimum required.
    As it is, I'm safely above them with a clock speed of 8Mhz and a minimum instruction cycle time of 500nS

    What gets returned is zero for each nibble despite there being non zero data present at the address(es)

    I should probably post this in the Microchip forum as I've written this project in assembler but it's really more of a question about whether anyone has successfully read data from a HD44780 controller based display and if so, what did you do that I am missing or not doing in steps 1) to 8) ?

    The E,RS and R/W lines all act as expected when viewed on an external logic analyser.
    (Sorry, I have no idea why the formatting below has become shot to pieces)



    Code:
    ;-------------------------------
    readnib:                               ;// Reads two nibbles from LCD. TOP MSB first.                                     
                                              ;// RS,RW are set prior to call. 
                                              ;// RS and RW govern whether call returns DDRAM data or status register
                                              ;// Call returns data read from LCD in "nibblein"
            clrf        nibblein            ;// zero nibblein
            movlw    b'00001111'       ;// Switch relevant port directions to inputs
            movwf    TRISA              ;// PORTA A0-A3 correspond to D4-D7 on LCD
            btfss    Eflag,0               ;// Eflag = 1? (Selects either LCD Bank1 or Bank2)
            bra        set_En1            ;// It's zero so use Enable1 for Bank1
            bsf        E2                    ;// It's one so use Enable2 for Bank2
            bra        done_En
    set_En1:
            bsf        E1                    ;// E1 = 1
    done_En:
            movf    PORTA,w             ;// Get data  = xxxxMMMM
            bcf        E1                    ;// Lower Enable line
            bcf        E2
                                                ;// LATA      = 76543210 (M=MSB from LCD)    
            andlw    b'00001111'        ;// AND out MSB nibble of first data nibble
            movwf    nibblein             ;//           = 0000MMMM
            swapf    nibblein,f            ;//           = MMMM0000 reverse order of nibble 
            btfss    Eflag,0                ;// Eflag = 1?
            bra        set_En1_            ;// It's zero so set Enable1
            bsf        E2                     ;// It's one so set Enable2
            bra        done_En_
    set_En1_:
            bsf        E1
    done_En_:
            movf    PORTA,w              ;// Get data = xxxxLLLL
            andlw    b'00001111'         ;// AND out top part of PORT = 0000LLLL
            iorwf    nibblein,f              ;// OR it into nibble        = MMMMLLLL 
            
            bcf        E1                     ;// lower enable line
            bcf        E2
            bcf        RS                     ;// RS and RW back to write mode before...
            bcf        RW                    ;//
            nop                               ;// ...setting ports to outputs
            movlw    b'00000000'        ;// 
            movwf    TRISA                ;// PORTA is now output.
            clrf        LATA                  ;// Zero port for neatness... and
            return                             ;// .. return with data in "nibblein"
    ;-------------------------------

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Fanatical Contributor Tim's Avatar
    Join Date
    Jan 2003
    Posts
    7,748
    Thumbs Up
    Received: 51
    Given: 96
    Total Downloaded
    1.32 GB

    0 Not allowed!

    Default Re: Reading data from a LCD display ?

    A very long time ago I did do some reading of the memory in those devices but I think I was using another compiler and there was a command called LCDREAD
    Tim

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Cruster
    Guest Cruster's Avatar

    0 Not allowed!

    Default Re: Reading data from a LCD display ?

    Solved.

    I'd omitted to turn the comparitors off in this device (18F2321) They're connected to PORTA .0 to PORTA.3 which doesn't affect those lines when used as outputs but did affect the lines when I switched them over to inputs.

    With the comparitors now turned off -

    Code:
            movlw    b'00000111'
            movwf    CMCON            ;// Comparitors off
    - rather then held in reset (as I had previously)

    Code:
            clrf        CMCON
    everything works perfectly.

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. [SOLVED !] Reading from HD44780 LCD
    By PaperWeight in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 24th March 2013, 14:06
  2. [SOLVED !] Lcd Characters Display Ground Inused Data
    By Cocoloco in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 8th April 2009, 03:30
  3. lcd display
    By rverm in forum Proton Plus Compiler v3
    Replies: 1
    Last Post: 21st December 2008, 02:04
  4. Reading serial data & comparing strings
    By SimonJA in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 16th September 2008, 08:56
  5. Problems outputting data/reading data with Logic Analyser
    By Stephen Moss in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 11th December 2007, 14:19

Tags for this Thread

Posting Permissions

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