#define __AD0832_H__
# Define uchar unsigned characters
# Define uint unsigned integer
sbit cs=p 1^0;
sbit clk=p 1^ 1;
sbit di=p 1^2;
sbit do=p 1^2;
//uchar result();
#endif
#ifndef __ 1602_H__
#define __ 1602_H__
# Define uchar unsigned characters
# Define uint unsigned integer
sbit rs=p2^0;
sbit rw=p2^ 1;
sbit e=p2^2;
void lcdinit(); //initialization
void write _ com(uchar com); //Write command
void write _ dat(uchar dat); //Write bytes
void showstr(uchar add,uchar line,uchar * s); //Write characters
void showchar(uchar add,uchar line,uchar p); //Write bytes
//void BF _ check(); //Busy sign detection
Void delayms (unit time); //Internal delay
#endif
# include & ltreg52.h & gt
# contains "1602.h"
Invalid delay (unit time)
{
uint x,y;
For(x = time; x & gt0; x -)
for(y = 1 12; y & gt0; y-);
}
/*void bf_check(void) // Busy flag detection
{
P0 = 0xff
RW = 0;
RS = 1;
e = 1;
delay ms( 10);
And ((P0 & amp0x80) = = 0x80);
e = 0;
}*/
Void write _ com(uchircom)// write command
{
Delems (5);
//BF _ check();
e = 0;
RW = 0;
RS = 0;
Delems (5);
e = 1;
P0 = com
Delems (5);
e = 0;
}
Void write_dat(uchar dat) // Write a byte.
{
Delems (5);
//BF _ check();
e = 0;
RW = 0;
RS = 1;
Delems (5);
e = 1;
P0 = dat
Delems (5);
e = 0;
}
Void showstr (uchar add, uchar line, uchar * s)// Write characters.
{
Delems (5);
if(line==0)
write _ com(add+0x 80);
other
write _ com(add+0xc 0);
while(*s)
{
write _ dat(* s);
s++;
}
}
Void show char (uchar add, uchar line, uchar p)// write bytes.
{
Delems (5);
if(line==0)
write _ com(add+0x 80);
other
write _ com(add+0xc 0);
write _ dat(p);
}
Voildlcinit ()//Initialization
{
Delems (5);
write _ com(0x 38);
write _ com(0x 0 1);
write _ com(0x0c);
}
# contains "reg52.h"
# contains "1602.h"
# including "AD0832.h"
# contains "intrins.h"
uchar buf[3]= { 0 };
Uchar result (uchar con_word)
{
uchar i,dat 1 = 0;
CS = 0;
for(I = 0; I<4; i++)
{
con _ word & lt& lt= 1;
CLK = 1; _ nop _(); _ nop _();
if(con _ word & amp; 0x 80)DI = 1;
else DI = 0;
CLK = 0; _ nop _(); _ nop _();
}
for(I = 0; I<8; i++)
{
dat 1 & lt; & lt= 1;
CLK = 1; _ nop _(); _ nop _();
if(DO== 1)
dat 1 | = 0x 0 1;
CLK = 0; _ nop _(); _ nop _();
}
CS = 1;
Delems (5);
Return dat1;
}
void main()
{
//uchar I;
uint d;
lcdinit();
Delems (5);
while( 1)
{
D = result (0x0d) * 500.0/255;
buf[0]= d/ 100+' 0 '; //Adjust the ASCII of "0" by adding 48 to the variable character type.
buf[ 1]= d/ 10% 10+' 0 ';
buf[2]= d % 10+' 0 ';
Showstr (0,0, "current voltage");
//sprintf(buf," %7.2f ",d);
//showstr( 1, 1,buf);
showchar(4, 1,buf[0]);
showchar(5, 1,'.');
showchar(6, 1,buf[ 1]);
showchar(7, 1,buf[2]);
showchar(8, 1,' v ');
}
}
It might help you.