Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Setting up LCD on 16f877a

Status
Not open for further replies.

bryan1

Well-Known Member
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 :D
 
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.
 
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 :D
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top