Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 02, 2025, 08:02:42 20:02


Login with username, password and session length


Pages: [1]
Print
Author Topic: LCD error on portd  (Read 15563 times)
0 Members and 1 Guest are viewing this topic.
8051
Junior Member
**
Offline Offline

Posts: 38

Thank You
-Given: 0
-Receive: 14


« on: January 29, 2006, 04:43:36 16:43 »

Hi , Im new and trying to working on picbasic pro
i using pic16F877A
This is my running led code.

led is running.
but lcd not working
please help where i wrong.


lcd connection is
RS BIT  -- PORTD.0 (PIN 19)
R/W BIT -- PORTD.1 (PIN 20)
E BIT   -- PORTD.2 (PIN 21)

D4  ---  PORTD.3  (PIN 22)
D5  ---  PORTD.4  (PIN 27)
D6  ---  PORTD.5  (PIN 28)
D7  ---  PORTD.6  (PIN 29)





DEFINE LCD_DREG PORTD
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTD
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTD
DEFINE LCD_EBIT 2
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2


CMCON = 7
ADCON1 = 7

OUTPUT PORTD
OUTPUT PORTB
LOW PORTD.1
PAUSE 500
LOW PORTD.1

LCDOUT $FE,1
LCDOUT "RUNNING LED"


LOOP:
        HIGH PORTB.0
        PAUSE 50
        LOW PORTB.0
        PAUSE 50
        HIGH PORTB.1
        PAUSE 50
        LOW PORTB.1
        PAUSE 50
        HIGH PORTB.2
        PAUSE 50
        LOW PORTB.2
        PAUSE 50
        HIGH PORTB.3
        PAUSE 50
        LOW PORTB.3
        PAUSE 50
        HIGH PORTB.4
        PAUSE 50
        LOW PORTB.4
        PAUSE 50
        HIGH PORTB.5
        PAUSE 50
        LOW PORTB.5
        PAUSE 50
        HIGH PORTB.6
        PAUSE 50
        LOW PORTB.6
        PAUSE 50
        HIGH PORTB.7
        PAUSE 50
        LOW PORTB.7
        PAUSE 50
        GOTO LOOP
        END
Logged
tasosstr
Junior Member
**
Offline Offline

Posts: 75

Thank You
-Given: 95
-Receive: 14


« Reply #1 on: January 29, 2006, 05:44:37 17:44 »

Hello,

Try  R/W BIT to put direct to ground.

Best Regards,
Tasosstr
Logged
metal
Global Moderator
Hero Member
*****
Offline Offline

Posts: 2420

Thank You
-Given: 862
-Receive: 678


Top Topic Starter


« Reply #2 on: January 29, 2006, 06:08:57 18:08 »

Hi

The coorect way is to connect this way

'D4 --- PORTD.4
'D5 --- PORTD.5
'D6 --- PORTD.6
'D7 --- PORTD.7

'Not

'D4 --- PORTD.3
'D5 --- PORTD.4
'D6 --- PORTD.5
'D7 --- PORTD.6

No need to use Output PortD/PortB, use this instead:
Code:

TRISB = [COLOR=Red]0[/COLOR]
TRISD = [COLOR=Red]0[/COLOR]

Also LCDOUT takes care of TRISD any way, and make the used Port bits as outputs already.

Don't forget to define the crystal speed:
Code:

[B]Define[/B] Osc [COLOR=Red]4[/COLOR]


I don't know why you are using so many Pause statemnets as long as they have the same delay, use this way in order to make it easier for you to examine your firmware:
Code:

Delay:
[B]Pause[/B] [COLOR=Red]50[/COLOR]
[B]Return[/B]


You can use this as follows:
Code:

[B]GoSub[/B] Delay


I also see that you use High Port.Bit, this is not nes\cessary, provided you have cleared TRISB:
Code:

TRISB = [COLOR=Red]0[/COLOR]
[COLOR=Navy]' Now use this:[/COLOR]
PortB.[COLOR=Red]0[/COLOR] = [COLOR=Red]0[/COLOR]
[B]GoSub[/B] Delay
PortB.[COLOR=Red]0[/COLOR] = [COLOR=Red]1[/COLOR]
[B]GoSub[/B] Delay


Another way that makes your code much smaller:
Code:

i [B]Var[/B] [B]Byte[/B]

[B]For[/B] i = [COLOR=Red]0[/COLOR] [B]To[/B] [COLOR=Red]7[/COLOR]
PortB.[COLOR=Red]0[/COLOR][i] = [COLOR=Red]0[/COLOR]
[B]GoSub[/B] Delay
PortB.[COLOR=Red]0[/COLOR][i] = [COLOR=Red]1[/COLOR]
[B]GoSub[/B] Delay
[B]Next[/B] i


This will go through all PortB pins and make what you are doing.
Logged
Ph1l
Guest
« Reply #3 on: January 29, 2006, 06:09:00 18:09 »

Your LCD should be connected to PortD.4 to PortD.7 (not PortD.3 to PortD.6)
(The upper 4 bits)
Logged
8051
Junior Member
**
Offline Offline

Posts: 38

Thank You
-Given: 0
-Receive: 14


« Reply #4 on: January 30, 2006, 12:11:02 12:11 »

Thanks tasosstr , metal & PH1 for HELP,
Now it is working.
and special thanks to GREAT metal for Deeply explain code.
I also see that  code size also redused to use "TRIS"  and  "for/next"  command.
Logged
dideco
Junior Member
**
Offline Offline

Posts: 39

Thank You
-Given: 7
-Receive: 6


« Reply #5 on: February 01, 2006, 09:06:54 09:06 »

Also, don't forget to diasable bidirectional parallel slave register for port D. Otherwise a simple parasitic osscillation may interrupt your LCD display.
Logged
8051
Junior Member
**
Offline Offline

Posts: 38

Thank You
-Given: 0
-Receive: 14


« Reply #6 on: February 02, 2006, 02:54:50 02:54 »

Thanks dideco but what is the command line to disable ?
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC