Microcontroller › 8051 › houch pouch value of adc0808
- This topic has 1 reply, 2 voices, and was last updated 10 years, 4 months ago by Ashutosh Bhatt.
-
AuthorPosts
-
August 20, 2014 at 7:28 pm #3164swyam prakash singhParticipant
sir please resolve my error where my logic is getting wrong
i m interfacing adc 0808 in intereupt mode with at89c51 with lcd 16*2 in 4 bit method
but the error i m getting is houch pouch value between 000 to 255;
these 2 positon are correct and other are houch pouch
i have simulated on proteus now to check only and the result are on proteus;
mine code is written in c
code is
#include<reg51.h>
#define ADC P1
#define LCD P2
unsigned int adc_val[7];
sbit a=P3^0;
sbit b=P3^1;
sbit c=P3^2;
sbit ale=P3^3;
sbit sc=P3^4;
sbit eoc=P3^5;
sbit oe=P3^6;
sbit clk=P3^7;
sbit rs=P2^0;
sbit rw=P2^1;
sbit en=P2^2;
sbit sw=P2^3;
sbit flag=P2^7;
void timerdelay() interrupt 3
{
clk=~clk;
}
void delay(int x)
{
unsigned int i,j;
for(i=0;i<127;i++)
for(j=0;j<x;j++);
}void cmd(unsigned int x)
{
unsigned int temp1 ,temp2;temp1=x;
temp1=temp1&0xf0;
LCD=temp1;
rs=0;rw=0;en=1;en=0;
delay(1);
temp2=x;
temp2=temp2<<4;
temp2=temp2&0xf0;
LCD=temp2;
rs=0;rw=0;en=1;en=0;
}
void dat(unsigned int x)
{
unsigned int temp1 ,temp2;
temp1=x;
temp1=temp1&0xf0;
LCD=temp1;
rs=1;rw=0;en=1;en=0;
delay(1);
temp2=x;
temp2=temp2<<4;
temp2=temp2&0xf0;
LCD=temp2;
rs=1;rw=0;en=1;en=0;
}
void init()
{
cmd(0x28);
cmd(0x01);
cmd(0x06);
cmd(0x0e);
}void lcdstring(unsigned char *string)
{while(*string!=’