LCDOUT 4-bit data on 8-bit setting


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2006
    Posts
    12

    Default LCDOUT 4-bit data on 8-bit setting

    Hey,

    Im having trouble on a PIC16F88, as far as i can tell the code should be outputting the data on all eight pins of PORTB, but pins 4-7 are allways low, see the example below:

    DEFINE OSC 8

    Define LCD_DREG PORTB ' Port for LCD Data
    Define LCD_DBIT 0 ' Starting Data bit (0 or 4) if 4-bit bus Use LOWER 4 bits of Port
    Define LCD_RSREG PORTA ' Port for RegisterSelect (RS) bit
    Define LCD_RSBIT 6 ' Port Pin for RS bit
    Define LCD_EREG PORTA ' Port for Enable (E) bit
    Define LCD_EBIT 7 ' Port Pin for E bit
    Define LCB_BITS 8 ' Using 4-bit bus
    Define LCD_LINES 4 ' Using 2 line Display
    Define LCD_COMMANDUS 2000 ' Command Delay (uS)
    Define LCD_DATAUS 200 ' Data Delay (uS)


    init:
    OSCCON = %01110000 '8 MHz Internal Oscillator
    Pause 2000 'Safe Start Up Delay


    CMCON = 7
    ADCON1 = 7
    ANSEL = %00000000
    TRISA = %00000000
    TRISB = %00000000
    PORTA = %00000000
    PORTB = %00000000

    main:

    LCDOUT %11111111
    PAUSE 1000

    goto main

    end

    Regards,
    Daniel

  2. #2
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default Typo is the likely cause !!!

    Define LCB_BITS 8 ' Using 4-bit bus

    The comment doesnt match the parameter specified but the real problem is that you have typed LCB instead of LCD

    Because you dont have a valid DEFINE it is using the default value which is for 4 bits.

    Hope that helps

    Keith
    Keith

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

  3. #3
    Join Date
    Jun 2006
    Posts
    12


    Did you find this post helpful? Yes | No

    Default

    Thanks, that was it.. Its amazing how I could miss it after reading through the code so many times..

    One more quick question, is it possible to clear a single line of an lcd display, or atleast fill it with blank characters?

  4. #4
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by breesy
    or atleast fill it with blank characters?
    Not efficient and code heavy but works – there must be a better way?
    Code:
    Line2Clr Var Byte
    X var Line2Clr 'reuse variable with alias to save RAM
    
    Line2Clr = 148 ' clear line 3 or 4x20 LCD (for example)
    Gosub ClrLine
    
    rest of program here
    
    ClrLine: ' subroutine
      LCDOUT $FE,Line2Clr,32,32	' clear 148 and 149 with 32 (ascii blank)
      FOR X = 0 to 8 ' clear rest of line
        LCDOUT 32,32
      NEXT X
    RETURN
    Paul Borgmeier
    Salt Lake City, Utah
    USA
    Last edited by paul borgmeier; - 26th June 2006 at 08:01.

  5. #5
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by breesy
    Thanks, that was it.. Its amazing how I could miss it after reading through the code so many times..
    We have all been there and done that in one way or another

    One more quick question, is it possible to clear a single line of an lcd display, or atleast fill it with blank characters?
    This is how I do it. I have a variable called "line" that I use for specifying which line of the LCD I want to go to the beginning of, and then specify CONstants for Line1, Line2 etc

    This is the sub that I use to clear the LCD (actually it fills it with spaces)

    Code:
           Line        var byte            ' Line of Display to act on
           Line1       con $02             ' Home position
           Line2       con $C0             ' Start of Line2
    
    .......
    
            Line = Line2
            Gosub Blankline
    
    
    .......
    
    BlankLine:       ' **** This clears the whole line of the display ****
            LCDOut $FE, Line, REP " "\16 ' Send 16 spaces to clear the line
            Return   ' **** End of BlankLine ***
    This could be extended further by changing the "16" to a variable name thereby giving the ability for a varying number of repeated characters.

    You could go the whole hog and change it to LCDout $FE, Line,REP Char\Charcount
    which would allow you to specify the Line, Character and number of characters to write to the display but I guess than you would have to call it something other than "Blankline"
    Keith

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

  6. #6
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by keithdoxey
    BlankLine: ' **** This clears the whole line of the display ****
    LCDOut $FE, Line, REP " "\16 ' Send 16 spaces to clear the line
    Return ' **** End of BlankLine ***
    Keith,
    Nice and clean - sweet!

    Paul

  7. #7
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Thanks Paul, but the only thing I can really take credit for is putting in a subroutine called "BlankLine". The syntax used is clearly shown on the LCDout page of the PBP manual
    Keith

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

Similar Threads

  1. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  2. Making a menu
    By chrisshortys in forum mel PIC BASIC Pro
    Replies: 36
    Last Post: - 12th November 2008, 19:54
  3. MAX1247 4-Channel, 12-Bit ADC
    By Atom058 in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 15th December 2006, 23:38
  4. Internal EEPROM Read/write Addressing Errors with 18F PIC's
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 18
    Last Post: - 12th July 2005, 19:42
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

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