+ Reply to Thread
Results 1 to 3 of 3

Thread: Setting up LCD on 16f877a

  1. #1
    Super Moderator bryan1 Excellent bryan1 Excellent bryan1 Excellent bryan1 Excellent bryan1 Excellent bryan1 Excellent bryan1 Excellent bryan1 Excellent
    Join Date
    Aug 2004
    Location
    Adelaide Hills Sth Oz
    Posts
    1,088
    Blog Entries
    4

    Default Setting up LCD on 16f877a

    Hiya Guy's,
    I'm now on building up a development box and it contains my 16f877a development board, a 20x4 LCD, 4x4 keypad and I've made up a 3-9 volt converter and got the board running of 2 AA rechargable batteries. Now for the question all the assembly code I've got always use one port for the LCD but I want to use the r/s, r/w and E lines using port E and the data lines in 4 bit mode using the 4 lower bits in portA. I know this is probably a basic question but how would I setup the EQU's to handle the lcd lines for the 2 different ports. Would the code below work or would I need to clarify more for portA if I needed to use the rest of the port.
    Code:
    LCD_DATA        EQU	PORTA          
    LCD_TRIS         EQU	TRISA
    LCD_CTRL        EQU	PORTE           
    ; PORT E control lines
    LCD_E             EQU	2              
    LCD_RW          EQU	1               
    LCD_RS           EQU	0
    
    Cheers Bryan
    " The only way to avoid human error is to avoid the use of humans"


  2. #2
    atferrari Good atferrari Good atferrari Good
    Join Date
    Oct 2003
    Location
    Buenos Aires - Argentina
    Posts
    573

    Default From my currently working code

    Your should do something like this:

    Code:
    ;I/O PORTS - ASSOCIATED REGISTERS
    
    ;This type of EQU is possible when registers are defined
    ;ahead in the respective .inc file for the processor.
    
    PORT_TEST		EQU	PORTA
    PORT_LCD_CTRL	EQU	PORTA
    PORT_INPUTS		EQU	PORTB
    PORT_OUTPUT		EQU	PORTD
    PORT_LCD_DATA	EQU	PORTD
    ;---------------------------------------------------------
    
    ;I/O PINS
    
    ;LCD DISPLAY
    
    #DEFINE LCD_E	PORT_LCD_CTRL,2	;LCD Enable control				
    #DEFINE LCD_RS	PORT_LCD_CTRL,3	;LCD Register selection control
    
    ;LCD_RW control pin is not used. Its pin in the LCD is kept grounded
    ;No "write"; only "read" instructions. A delay replaces BUSY flag check.
    
    Agustín Tomás
    In theory, there is no difference between theory and practice. In practice, however, there is.

  3. #3
    Super Moderator bryan1 Excellent bryan1 Excellent bryan1 Excellent bryan1 Excellent bryan1 Excellent bryan1 Excellent bryan1 Excellent bryan1 Excellent
    Join Date
    Aug 2004
    Location
    Adelaide Hills Sth Oz
    Posts
    1,088
    Blog Entries
    4

    Default

    Hiya Guy's
    I tried the lcd using PORTE for the rs, r/w and E pins and used PORTC for the data lines without sucess. I'm using mplab as the assembly and my icd2 clone for the programmer. The best part is I've got the box setup and when I put the programming header on and switch the power on mplab see's the 16f877a instantly. I ended up just using PORTC for the lcd and it worked perfectly, well that will do for the time being but I remember I did read a thread here in the past about troubles with PORTE. I wonder if this is why I'm having troubles. As all my programming is done on my laptop in the shed I don't have the code handy. Anway the code I'm using is Nigel's tutorial 9.2 which is the keypad and lcd and I've changed the port parameters to suit my setup just to make sure everything works. As I'm heading up the bush tomorrow for work for 2 weeks I'll try and work it out.

    Cheers Bryan
    " The only way to avoid human error is to avoid the use of humans"

+ Reply to Thread

Tags for this Thread