Can I change LCD enable bit to port A instead of Port B ?
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2013
    Posts
    471

    Default Can I change LCD enable bit to port A instead of Port B ?

    Hello. Standard DEFINEs indicate that LCD enable port is Port.B and uses PortB.3

    Code:
    ' Set LCD Data port 
    DEFINE LCD_DREG PORTA  
    ' Set starting Data bit (0 or 4) if 4-bit bus 
    DEFINE LCD_DBIT 0  
    ' Set LCD Register Select port 
    DEFINE LCD_RSREG PORTA  
    ' Set LCD Register Select bit 
    DEFINE LCD_RSBIT 4  
    ' Set LCD Enable port 
    DEFINE LCD_EREG PORTB  
    ' Set LCD Enable bit  
    DEFINE LCD_EBIT 3  
    ' Set LCD bus size (4 or 8 bits) 
    DEFINE LCD_BITS 4  
    ' Set number of lines on LCD  
    DEFINE LCD_LINES 2  
    ' Set command delay time in us 
    DEFINE LCD_COMMANDUS 1500  
    ' Set data delay time in us 
    DEFINE LCD_DATAUS 44  
    


    As I understand, it is set by these two lines:

    Code:
    DEFINE LCD_EREG PORTB ' Set LCD Enable bit DEFINE LCD_EBIT 3 ' Set LCD bus size (4 or 8 bits)


    So the question is, can I change it to PortA (where other lcd pins are connected) and use say, PortA.7 for that? it would be easy to trace PCB in that way.

    Code:
    
    DEFINE LCD_EREG PORTA  
    ' Set LCD Enable bit  
    DEFINE LCD_EBIT 7  
    ' Set LCD bus size (4 or 8 bits) 
    


    Correct? I have no hardware on hands right now, so can't check, this is why I'm asking....


  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    1,653

    Default Re: Can I change LCD enable bit to port A instead of Port B ?

    melabs made this really useful thing, a couple of minutes with it will give you the answers you seek
    http://melabs.com/downloads/PBP_Manual_0609_260.pdf
    This is more entertaining than Free to Air TV

  3. #3
    Join Date
    Feb 2013
    Posts
    471

    Default Re: Can I change LCD enable bit to port A instead of Port B ?

    Believe or not, code above is taken from that manual, and there is no further clarification why they used PORTA for data lines and PortB for enable register.

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    1,653

    Default Re: Can I change LCD enable bit to port A instead of Port B ?

    looks pretty clear to me
    The LCD may be connected to the PIC MCU using either a 4-bit bus or an 8-bit bus. If an 8-bit bus is used, all 8 bits must be on one port. If a 4-bit bus is used, the top 4 LCD data bits must be connected to either the bottom 4 or top 4 bits of one port. Enable and Register Select may be connected to any port pin. R/W may be tied to ground if the LCDIN command is not used.
    PBP assumes the LCD is connected to specific pins unless told otherwise using DEFINEs. It assumes the LCD will be used with a 4-bit bus with data lines DB4 - DB7 connected to PIC MCU PORTA.0 - PORTA.3, Register Select to PORTA.4 and Enable to PORTB.3.
    This is more entertaining than Free to Air TV

  5. #5
    Join Date
    Aug 2003
    Location
    Australia
    Posts
    1,041

    Default Re: Can I change LCD enable bit to port A instead of Port B ?

    I literally did it yesterday. If porta bit 4 is open collector for the device, it will need a pullup resistor.

  6. #6
    Join Date
    Feb 2013
    Posts
    471

    Default Re: Can I change LCD enable bit to port A instead of Port B ?

    Yes, silly me.

    My current setup looks like this. IC is PIC16F886. LCD data pins are connected to PORTC.0-PORTC.3, Enable connected to PortA.6 and reset pin to Porta.7

    Whole code is here:

    Code:
    include "modedefs.bas"
    TRISA=%00000000  'SET A TO OUTPUT
    TRISC=%00000000
    ANSEL=%00000000  'SET AD TO DIGITAL A
    ANSELH=%00000000   ' ADC OFF B
    OSCCON=%01110101  'SET FREQUENCY TO 8MHZ
    WPUB=%00000000    'turn off Pullups
    CM1CON0=0         'DISABLE COMPARATORS
    CM2CON0=0         'SAME HERE
    
    DEFINE OSC 8
    ' Set LCD Data port 
    DEFINE LCD_DREG PORTC  
    ' Set starting Data bit (0 or 4) if 4-bit bus 
    DEFINE LCD_DBIT 0  
    ' Set LCD Register Select port 
    DEFINE LCD_RSREG PORTA  
    ' Set LCD Register Select bit 
    DEFINE LCD_RSBIT 8  
    ' Set LCD Enable port 
    DEFINE LCD_EREG PORTA  
    ' Set LCD Enable bit  
    DEFINE LCD_EBIT 7  
    ' Set LCD bus size (4 or 8 bits) 
    DEFINE LCD_BITS 4  
    ' Set number of lines on LCD  
    DEFINE LCD_LINES 2  
    ' Set command delay time in us 
    DEFINE LCD_COMMANDUS 1500  
    ' Set data delay time in us 
    DEFINE LCD_DATAUS 44
    
    pause 500
    
    ahaia:
    
    lcdout $fe, $c0, "test"
    
    goto ahaia

  7. #7
    Join Date
    Feb 2013
    Posts
    471

    Default Re: Can I change LCD enable bit to port A instead of Port B ?

    fixed, set rsbit to 7 and ebit to 6. When compiling with 8 and 7, compiler was giving error, but I have not noticed it!

Similar Threads

  1. Interrupt on RB port change with PIC18F23K20
    By microuser in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th January 2011, 09:43
  2. encoder port change
    By l_gaminde in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th September 2009, 19:41
  3. LCD R/S works on Port A but not Port B
    By TDonBass in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th February 2009, 12:41
  4. LCD port bit choices
    By rossfree in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd September 2006, 10:22
  5. LCD 4-bit mode affecting rest of port?
    By Mark Scotford in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 22nd August 2005, 08:43

Members who have read this thread : 19

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