| ??? 09/25/07 14:34 Read: times |
#144984 - Codes for my application Responding to: ???'s previous message |
Hello Russ Cooper, This is my code.
#include<reg52.h>
sfr MYDATA=0x90; //p1 connected to D0-D7 of ADC0804
sfr outdata=0x80; //p0 connected to D0-D7 of LCD pins
sbit INTR=P2^2;
sbit rd=P2^3;
sbit wr=P2^4;
sbit rs=P2^5;
sbit rw=P2^6;
sbit en=P2^7;
//Function Declaration//
void temperature(unsigned char value);
void MSDelay(unsigned int itime);
void lcdcmd(unsigned char value);
void lcddata(unsigned char value);
//Main Program//
void main(void)
{
unsigned char value;
TMOD=0x20; // Mode 2 of timer1 is selected.
TH1=0xFD;
SCON=0x50;
TR1=1;
lcdcmd(0x38);
lcdcmd(0x0e);
lcdcmd(0x80);
lcdcmd(0x06);
lcdcmd(0x80);
lcddata('B');
lcddata('O');
lcddata('D');
lcddata('Y');
lcddata(' ');
lcddata('T');
lcddata('E');
lcddata('M');
lcddata('P');
lcddata('E');
lcddata('R');
lcddata('A');
lcddata('T');
lcddata('U');
lcddata('R');
lcddata('E');
lcdcmd(0xc0);
MYDATA=0xFF; //make p1 an input
INTR=1; //make INTR and input
rd=1; //set RD high
wr=1; //set WR high
while(1)
{
wr=0; //send WR pulse
wr=1;
rd=0; //send RD pulse
value=MYDATA; //read from ADC0848
temperature(value);
rd=1;
}
}
//Subroutine Programs//
void lcdcmd(unsigned char value)
{
outdata=value;
rs=0;
rw=0;
en=1;
MSDelay(1);
en=0;
return;
}
void lcddata(unsigned char value)
{
outdata=value;
rs=1;
rw=0;
en=1;
MSDelay(1);
en=0;
return;
}
void temperature(unsigned char value)
{
unsigned char x,d1,d2,d3;
x=value/10;
d1=value%10; //LSB
d2=x%10;
d3=x/10; //MSB
value=d1;
lcdcmd(0xc8);
lcddata(d1);
value=d2;
lcdcmd(0xc9);
lcddata(d2);
value=d3;
lcdcmd(0xca);
lcddata(d3);
lcdcmd(0xcb);
lcddata('o');
lcddata('C');
return;
}
void MSDelay(unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}
|
| Topic | Author | Date |
| Doubt in 8052 | 01/01/70 00:00 | |
| Need more info | 01/01/70 00:00 | |
| Pullups on P0? | 01/01/70 00:00 | |
| Pull ups | 01/01/70 00:00 | |
| ... and? | 01/01/70 00:00 | |
| Codes for my application | 01/01/70 00:00 | |
| Incomplete LCD Initialization | 01/01/70 00:00 | |
| Next steps | 01/01/70 00:00 | |
| Two questions/suggestions | 01/01/70 00:00 | |
| U r just one step back, march ahead... | 01/01/70 00:00 | |
| Brightness? | 01/01/70 00:00 | |
| thanx, its what u understood! | 01/01/70 00:00 | |
| they r just bothering u! try mine | 01/01/70 00:00 | |
| it can be problem of EN pin.... | 01/01/70 00:00 | |
| Pull Up | 01/01/70 00:00 | |
| One more doubt | 01/01/70 00:00 | |
New topic! | 01/01/70 00:00 |



