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.

p18f4550 lcd display help

Status
Not open for further replies.

ravindrareddy2131

Newbie level 4
Newbie level 4
Joined
Jul 12, 2011
Messages
6
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,370
hi everyone,
i had a problem with reading temperature values on 16*2 lcd. i am transmitting real temperature value through xbee and another xbee transceiver is receiving them successfully but i'm unable to display them on lcd. here is my program which is written in MPLAB. could anyone please help me..

#include<p18f4550.h>
#include<usart.h>
#include<delays.h>

#define ldata PORTD
#define rs PORTBbits.RB0
#define rw PORTBbits.RB1
#define en PORTBbits.RB2
#define led PORTDbits.RD1
#define buzzer PORTBbits.RB7

#pragma config FOSC=HS
#pragma config BOR=OFF
#pragma config PWRT=OFF
#pragma config WDT=OFF, DEBUG=OFF
#pragma config LVP=OFF
#pragma config MCLRE=ON
#pragma config PBADEN=OFF
#pragma config ICPRT=OFF

void lcdcmd (unsigned char);
void lcddata (unsigned char);
void MSDelay (unsigned int);


void main(void)

{
unsigned char C;
TRISB=0;
TRISC=1;
TRISD=0;
en=0;
MSDelay(250);
lcdcmd(0x38);
MSDelay(250);
lcdcmd(0x0E);
MSDelay(15);
lcdcmd(0x01);
MSDelay(15);
lcdcmd(0x06);
MSDelay(15);
lcdcmd(0x86);
MSDelay(15);
lcdcmd(0x01);
MSDelay(15);
lcddata('T');
MSDelay(15);
lcddata('E');
MSDelay(15);
lcddata('M');
MSDelay(15);
lcddata('P');
MSDelay(15);
lcddata(':');

RCSTA=0x90;
TXSTA=0x00;
SPBRG=31;
TRISCbits.TRISC7=1;
while(1)
{
while(PIR1bits.RCIF==0)
C=RCREG;
lcdcmd(0xC0);
MSDelay(15);
lcddata(C);
MSDelay(15);
lcddata(223);
MSDelay(15);
lcddata('C');
MSDelay(15);
}
}

void lcdcmd (unsigned char value)
{
ldata =value;
rs=0;
rw=0;
en=1;
MSDelay(1);
en=0;

}

void lcddata (unsigned char value)
{
ldata = value;
rs=1;
rw=0;
en=1;
MSDelay(1);
en=0;

}

void MSDelay (unsigned int itime)
{
unsigned int i;
unsigned int j;
for(i=0;i<itime;i++)
for(j=0;j<135;j++);
}
 

First problem I see is that you are using PORT bits for output. Use PORT only for input, use LAT for output, like this:

Code:
#define ldata PORTD
#define rs LATBbits.LATB0
#define rw LATBbits.LATB1
#define en LATBbits.LATB2
#define led LATDbits.LATD1
#define buzzer LATBbits.LATB7
I do not know if this is enough to solve your problem, but it certainly needs fixing.

Google RMW or Read Modify Write for the explanation why.

Hope this helps
 

The output should be in ascii.
try this out.
Code:
RCSTA=0x90;
TXSTA=0x00;
SPBRG=31;
TRISCbits.TRISC7=1;
while(1)
{
while(PIR1bits.RCIF==0)
C=RCREG;
lcdcmd(0xC0);
MSDelay(15);
lcddata([COLOR="#FF0000"]'0'+(C >> 4)[/COLOR]);
lcddata([COLOR="#FF0000"]'0'+(C & 0xf)[/COLOR]);
MSDelay(15);
lcddata(223);
MSDelay(15);
lcddata('C');
MSDelay(15);
}
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top