Thread starter
#1
Hello everyone. I'm very new here and completely new to microcontrollers.
I'm trying to interface ADC0804 with Serial port (RS232) using 8051 micocontroller (AT89S52).
I've attached the circuit diagram I have followed to achieve my means, and I have succeeded in the Analog to Digital Conversion because my LEDs lit up the way they were supposed to.
This is the code I programmed into my AT89S52 microcontroller:
However, when I tried to connect my system to my PC by using a USB to RS232 converter, I could not receive any data on the hyperterminal. I selected Bit rate as 9600bps, Data bits 8, Parity as none, Stop bit 1, Flow control none, but was unable to receive anything. I also updated the latest driver for windows 7 to connect the RS232 to my USB port...
I don't understand where I'm going wrong. PLEASE HELP. THANK YOU IN ADVANCE.
I'm trying to interface ADC0804 with Serial port (RS232) using 8051 micocontroller (AT89S52).
I've attached the circuit diagram I have followed to achieve my means, and I have succeeded in the Analog to Digital Conversion because my LEDs lit up the way they were supposed to.
This is the code I programmed into my AT89S52 microcontroller:
Code:
// Program to read the values of ADC and serially tranmitting it to PC.
#include<reg51.h>
sbit wr= P2^0; // Write pin. It is used to start the conversion.
sbit rd= P2^1; // Read pin. It is used to extract the data from internal register to the output pins of ADC.
sbit intr= P2^2; // Interrupt pin. This is used to indicate the end of conversion. It goes low when conversion is complete.
void transmit() // Function for serial tranmission of data.
{
SBUF=P1;
while(TI==0);
TI=0;
}
void delay(unsigned int msec ) // The delay function provides delay in msec.
{
int i ,j ;
for(i=0;i<msec;i++)
for(j=0; j<1275; j++);
}
void adc() //Function to read the values from ADC and tranmit serially.
{
rd=1;
wr=0;
delay(2);
wr=1;
while(intr==1);
rd=0;
transmit();
delay(2);
intr=1;
}
void init() // Intialize timer 1 in mode 2 for serial transmission. The baud rate is set to 9600bps.
{
TMOD=0x20;
TH1=0xFD;
SCON=0x50;
TR1=1;
}
void main()
{
P1=0xff; // Declare P1 as input port.
init();
while(1)
{
adc();
}
}
I don't understand where I'm going wrong. PLEASE HELP. THANK YOU IN ADVANCE.
Attachments
-
80.5 KB Views: 509