Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to configure 16*2 LCD with pic 16f876A?

Status
Not open for further replies.

saviourm

Junior Member level 3
Joined
Apr 28, 2011
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,519
Hi guys
My problem is this: when I am using PORTA to control the LCD ,RA0 as Register Select,RA1 as R/W the LCD does not work.On the other hand when I used PortC to control the LCD it worked properly.
Can someone give an advice how to configure PortA in assembley please?
Thanks
 

Switch off analog functions for PORTA (datasheet !!).
 
I tried the following
config:
bsf STATUS,5
movlw B'00000111'
movwf ADCON1
movwf B'00000111
movlw CMCON
movlw B'00000000'
movwf TRISA
does not work any way

---------- Post added at 21:26 ---------- Previous post was at 20:59 ----------

I read the datasheet three times about ADC and compartors modules
But I didn't make any progress.Below is my programm.
Thankyou in advance for your help.
org 0
bsf STATUS,5
movlw B'00000111'
movwf ADCON1
movlw B'00000111
movwf CMCON
movlw H'0000'
movwf TRISA
movlw H'0000'
movwf TRISB
bcf STATUS,5
call LCDcmd
clrf COUNT3
Loop movf COUNT3,0
call w_LCD
xorlw A'T'
btfsc STATUS,2
Call Line2
incf COUNT3,1
goto Loop
LCDcmd bcf PORTA,0
movlw H'0001'
movwf PORTB
Call E_Pulse
movlw H'0038'
movwf PORTB
Call E_Pulse
movlw H'000F'
movwf PORTB
Call E_Pulse
return
w_LCD bsf PORTA,0
Call text
movwf PORTB
Call E_Pulse
return
E_Pulse
bsf PORTA,1
Call Delay
bcf PORTA,1
return
Delay
Loop1 decfsz COUNT1,1
goto Loop1
decfsz COUNT2,1
goto Loop1
return
text
addwf PCL,1
retlw A'S'
retlw A'A'
retlw A'V'
retlw A'I'
retlw A'O'
retlw A'U'
retlw A'R'
retlw A' '
retlw A'M'
retlw A'U'
retlw A'S'
retlw A'C'
retlw A'A'
retlw A'T'
return
Line2 bcf PORTA,0
movlw H'00C0'
movwf PORTB
Call E_Pulse
clrf COUNT3
Loop4 movf COUNT3,0
call w_LCD
xorlw A'T'
btfsc STATUS,2
goto stop
incf COUNT3,1
goto Loop4
stop bcf PORTA,0
movlw H'001C'
movwf PORTB
Call E_Pulse
Call Delay
goto stop
return
end

---------- Post added at 21:51 ---------- Previous post was at 21:26 ----------

Thank you for your cooperation I managed by myself thankyou!!!!!!!!
 

First, use the 'Code' tags (the # icon) to post a program, it will be more readable.
A snippet from your program:
Code:
E_Pulse 
     bsf PORTA,1
     Call Delay
     bcf PORTA,1
return
But the above is a possible error because you wrote this:
"RA0 as Register Select, RA1 as R/W"
The LCD has a dedicated E pin, using R/W instead is wrong!!

If you are working in Proteus, please post here the whole project in a ZIP.
But - at least - the sources (both, also the working one), and your schematic.
 

One problem is you are attempting to access SFRs in different banks, try using the the "banksel" directive:

bsf STATUS, RP0 ; Instead of this
banksel ADCON1 ; Use this before accessing SFRs, banksel manages RP0 and RP1 for you.

like so ---

banksel ADCON1
movlw B'00000111'
movwf ADCON1

banksel CMCON
movlw B'00000111
movwf CMCON

banksel TRISA
movlw H'0000'
movwf TRISA

banksel TRISB
movlw H'0000'
movwf TRISB
...
...

Over use has no effect, under use can be a serious problem. Banksel basicly manages the RP0 and RP1 bits in the STATUS SFR.

---------- Post added at 21:18 ---------- Previous post was at 21:09 ----------

Beside the datasheet of the MCU you're using in your design:

PIC16F87XA Datasheet

Reference pg 17, PIC16F876A/877A REGISTER FILE MAP

You should also have a copy of the assembler/compiler you are using for your project:

MPASM™ Assembler, MPLINK™ Object Linker MPLIB™ Object Librarian User’s Guide

Reference pg 50, banksel - GENERATE BANK SELECTING CODE

Having proper documenation on hand can greatly reduce stress levels and aspirin intake rates!
 
Last edited:

Hi guys
My problem is this: when I am using PORTA to control the LCD ,RA0 as Register Select,RA1 as R/W the LCD does not work.On the other hand when I used PortC to control the LCD it worked properly.
Can someone give an advice how to configure PortA in assembley please?
Thanks


I SUGGEST YOU TO ADD A PULL UP RESISTOR (4K7 Ohms) ON EVERY PIN FROM PORTA, THAT YOU USE TO CONTROL THE LCD.

:-D
 

Attachments

  • PULL UP RESISOTR ON PORTA CONNECTED LCD.JPG
    PULL UP RESISOTR ON PORTA CONNECTED LCD.JPG
    124.3 KB · Views: 112

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top