Can defines be changed with port input?


Closed Thread
Results 1 to 13 of 13

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Question Continuing Saga

    Quote Originally Posted by Acetronics
    Hi,Joe

    Mhhhh, now, If you DO NOT send data one after the other , but specify WHERE you want it to be written ...

    Only 2 lines will be used ...

    But YOU MUST Tell PbP you USE a 4 LINES Display ... PbP can't think you only WANT 2 lines ... no DEFINE for unwanted lines !!!

    CQFD

    Alain.
    HI Alain,
    The thing is, if you check post #6, I am sending the data in a manner so as to tell PBP where to write each line, I would expect the software to delimit the display to the addresses available only to a 2 line display if it is defined as a 2 line, even with a 4 line display connected, but it displays all 4 lines. Now if I install a 2 line display, and send 4 lines of data as written in post 6, only the lines written for line 1 and line 2 will display. I would have expected the PIC to truncate the third and fourth lines when set to 2 lines, even when connected to a 4 line display. It appears that is not so. So I still have the question, what effect does DEFINE LCD_LINES have on the LCDOUT command?
    Regards
    JS

  2. #2
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default Look at the datasheet for the display

    OK. I didnt know what the LCD_LINES define actually did so I took a look in PBPPIC14.LIB and located this section of code.....

    Code:
        if (LCD_BITS == 8)
          if (LCD_LINES == 1)
            movlw   30h             ; 8-bit mode, 1 line, 5x7 font
          else
            movlw   38h             ; 8-bit mode, 2+ lines, 5x7 font
          endif
        else
          if (LCD_LINES == 1)
            movlw   20h             ; 4-bit mode, 1 line, 5x7 font
          else
            movlw   28h             ; 4-bit mode, 2+ lines, 5x7 font
          endif
        endif
    The "Function Set" register of the 44780 LCD controller chip has the following bits


    D7 = 0
    D6 = 0
    D5 = 1
    D4 = DL
    D3 = N
    D2 = F
    D1 = -
    D0 = -

    where

    DL = DataLength
    1 = 8 bits
    0 = 4 bits

    N = Number of lines
    1 = 2(+) lines
    0 = 1 line

    F = Font
    1 = 5x10 dots
    0 = 5x8 dots

    So looking at the code in the library file, the define is acted upon but is only used to correctly configure the display driver chip for the LCD display connected to it during initialisation.

    When you consider that there isnt a define for LCD_CHARS to declare how many characters are on a line then it follows that it cant do anything clever such as work out that you have reached the end of line 1 and move to the start of line 2.

    PBP does an awful lot of the hard work for you but there are times when you have to take care of some things yourself.
    Keith

    www.diyha.co.uk
    www.kat5.tv

Similar Threads

  1. Matrix Keypad routine
    By mister_e in forum Code Examples
    Replies: 134
    Last Post: - 18th September 2022, 20:30
  2. Input and Output on same Port
    By Frozen001 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th November 2008, 18:46
  3. Accessing Portion of Input Port
    By Frozen001 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 24th October 2008, 16:33
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50

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