yviswanathbe
Full Member level 4
micro 8051 + 89 c2051 + datasheet
Hi friends,
I am doing project named Auto Measurement of Current from power supply for one of my application.
I am amplifying the analog output using an OP-Amp OP07,the amplified output is given to ADC,there i am converting to digital,this digital value i am taking at one of the Port of microcontroller(89c2051).I want to get this value using serial communication.for that i have connected the microcontroller to max233.
my problem is no value is displayed in the hyperterminal.
can any body tell me what problem do i have?
The code i have used is
#include<reg52.h>
#include<stdio.h>
sbit adc_port=P1;
sbit rd = P3^0;
sbit wr = P3^1;
sbit CS=P1^2;
sbit intr=P1^3;
void conv();
void read();
void transmit(unsigned char);
unsigned char adc_val;
void main()
{
TMOD=0x20;
TH1=-3;
SCON=0x50;
TR1=1;
TI=1;
while(1)
{
conv();
read();
P3=adc_val;
}
}
void conv()
{
CS=0;
wr=0;
wr=1;
CS=1;
while(intr);
}
void read()
{
CS=0;
rd=0;
adc_val=adc_port;
rd=1;
CS=1;
}
void transmit(unsigned char data1)
{
SBUF=data1;
while(!TI);
TI=0;
}
thanks in advance.
Hi friends,
I am doing project named Auto Measurement of Current from power supply for one of my application.
I am amplifying the analog output using an OP-Amp OP07,the amplified output is given to ADC,there i am converting to digital,this digital value i am taking at one of the Port of microcontroller(89c2051).I want to get this value using serial communication.for that i have connected the microcontroller to max233.
my problem is no value is displayed in the hyperterminal.
can any body tell me what problem do i have?
The code i have used is
#include<reg52.h>
#include<stdio.h>
sbit adc_port=P1;
sbit rd = P3^0;
sbit wr = P3^1;
sbit CS=P1^2;
sbit intr=P1^3;
void conv();
void read();
void transmit(unsigned char);
unsigned char adc_val;
void main()
{
TMOD=0x20;
TH1=-3;
SCON=0x50;
TR1=1;
TI=1;
while(1)
{
conv();
read();
P3=adc_val;
}
}
void conv()
{
CS=0;
wr=0;
wr=1;
CS=1;
while(intr);
}
void read()
{
CS=0;
rd=0;
adc_val=adc_port;
rd=1;
CS=1;
}
void transmit(unsigned char data1)
{
SBUF=data1;
while(!TI);
TI=0;
}
thanks in advance.