-- New to electronics and microcontrollers --
I have seen a lot of schematics on how to interface the 8051 with a serial port. They all include the Max232 converter. Then I came across Wichit Sirichote's page and I found this: http://www.kmitl.ac.th/~kswichit/ap275/ap275.htm
I hooked it up as can be seen in the attached schematic.
It works wonderfully (through Hyperterminal). The program is at the bottom of this message.
Here are my questions:
- Why is it bad to hook it up like that?
- Will it damage the microcontroller if hooked up like that?
- What is the purpose of the Resistor-Capacitor combination on the RST pin (pin 9)?
- Any other comments on the other resistors (still don't understand pull-up and pull-down's purpose), the diode, and the transistors are welcomed and appreciated.
- Also any comments on the program and schematic are also welcomed and appreciated as well.
Thank you in advance for all your help and comments,
Salim
//------------------------------------------------------
sfr at 0x87 PCON;
sfr at 0x89 TMOD;
sfr at 0x8D TH1;
sfr at 0x98 SCON0;
sfr at 0x99 SBUF0;
sbit at 0x8E TR1;
sbit at 0x98 RI_0;
sbit at 0x99 TI_0;
void SerialLoop(void);
void main(void)
{
SCON0 = 0x50; // 01010000 bin. 8-bit UART; timer baud rate
TMOD = 0x20; // 00100000 bin. 8-bit auto reload timer
PCON = 0x80; // 10000000 bin. SMOD_0 on. Double the baud rate
TH1 = 253; // baud rate of 19200 with SMOD_0 and 11.0592 MHz
TR1 = 1; // turn on timer
while (1)
SerialLoop();
}
void SerialLoop(void)
{
unsigned char Acc;
while (!RI_0){} // wait for RI_0 = 1
Acc = SBUF0; // move buffer to accumulator
RI_0 = 0;
TI_0 = 0;
SBUF0 = Acc; // move accumulator to buffer
while (!TI_0){} // wait for TI_0 = 1
}
I have seen a lot of schematics on how to interface the 8051 with a serial port. They all include the Max232 converter. Then I came across Wichit Sirichote's page and I found this: http://www.kmitl.ac.th/~kswichit/ap275/ap275.htm
I hooked it up as can be seen in the attached schematic.
It works wonderfully (through Hyperterminal). The program is at the bottom of this message.
Here are my questions:
- Why is it bad to hook it up like that?
- Will it damage the microcontroller if hooked up like that?
- What is the purpose of the Resistor-Capacitor combination on the RST pin (pin 9)?
- Any other comments on the other resistors (still don't understand pull-up and pull-down's purpose), the diode, and the transistors are welcomed and appreciated.
- Also any comments on the program and schematic are also welcomed and appreciated as well.
Thank you in advance for all your help and comments,
Salim
//------------------------------------------------------
sfr at 0x87 PCON;
sfr at 0x89 TMOD;
sfr at 0x8D TH1;
sfr at 0x98 SCON0;
sfr at 0x99 SBUF0;
sbit at 0x8E TR1;
sbit at 0x98 RI_0;
sbit at 0x99 TI_0;
void SerialLoop(void);
void main(void)
{
SCON0 = 0x50; // 01010000 bin. 8-bit UART; timer baud rate
TMOD = 0x20; // 00100000 bin. 8-bit auto reload timer
PCON = 0x80; // 10000000 bin. SMOD_0 on. Double the baud rate
TH1 = 253; // baud rate of 19200 with SMOD_0 and 11.0592 MHz
TR1 = 1; // turn on timer
while (1)
SerialLoop();
}
void SerialLoop(void)
{
unsigned char Acc;
while (!RI_0){} // wait for RI_0 = 1
Acc = SBUF0; // move buffer to accumulator
RI_0 = 0;
TI_0 = 0;
SBUF0 = Acc; // move accumulator to buffer
while (!TI_0){} // wait for TI_0 = 1
}
Attachments
-
44.9 KB Views: 91