No, you can't connect these pins to the PC serial port.
The main reason is they are SPI pins, and you need to use the UART pins for this. The UART pins will be usually named RX and TX (though the datasheet will tell you)
Secondly, the voltages from the PC serial port are incompatible with your chip, so you you need something like the MAX232 suggested by AndrejaKo to translate the levels.
I suggest doing the following:
- Read the Wiki page on UART (linked to above)
- Read the datasheet - at the very least the UART section.
- Google for examples of using UART for your chip.
For the last point I did a quick google for "89S52 UART example" and got quite a few relevant pages back.
Here is some basic example code for the UART from one of them:
#include <REGX52.h>
#include "delay.h"
#include <stdio.h>
unsigned char temperature;
unsigned char humidity;
void uartInit(void)
{
SCON = 0x52;
TMOD = TMOD|0x20;
TH1 = 0xfd;
TR1 = 1;
}
void main(void)
{
uartInit();
for(;;)
{
printf("Temperature : %bu Humidity : %bu \n", temperature++, humidity++);
DelayMs(1000);
}
}
EDIT - to use the SPI pins to connect to a PC, you need the PC to have an SPI capable interface (which don't come as standard on most machines) To add one you will need an SPI host adapter like this which can be plugged into the PCs USB port.
USART is a device (or peripheral). SPI is a standard method of connecting things.
USART stands for Universal Synchronous/Asynchronous Receiver/Transmitter, and is the basic thing you need if you want to transmit using RS-232.422/485/etc. The Synchronous part of a USART is not used very often, and is sometimes that functionality is left out of the device-- and then it's called a UART (pronounced You-Art).
USARTs (with an appropriate RS-232/etc driver/receiver) are mainly used to talk with devices over a cable. Sometimes they are used to talk between devices on the same PCB, or within the same box, but it is much more common to talk with another device over a cable.
SPI, the Serial Peripheral Interface Bus, is a completely different thing than a USART. SPI is mainly used to talk with devices on the same PCB or in the same box. For example, an MCU talking with a digital temperature sensor. It is almost never used to talk over a cable, from box to box.
The nice thing about SPI is that it is super simple, and the devices using SPI do not have to be MCUs. USARTs almost always require that MCUs of some sort are on both ends of the communication link. But USARTs can be connected using less wires over longer distances.
Best Answer
Follow along in the datasheet.
Chapter 13: USI means Universal Serial Interface. It's a peripheral that can be programmed for either three-wire (SPI) or two-wire (I2C) communications. This ability to be configured for either serial protocol is why it's called "universal". USI is not a communications protocol, it's the configurable peripheral.
Chapter 13.3.1: The USI three-wire protocol is compatible with SPI. Use pins DI, DO, and USCK in this mode. This is for when you are using the microcontroller as an SPI master (13.3.2) or slave (13.3.3) for your application.
Chapter 18.6: The MISO and MOSI pins are used during serial programming of the microcontroller's flash and EEPROM memories. Here the microcontroller is acting as a slave to some external programmer that is the master.
Chapter 10.2.2: The MISO pin really the same pin as DO on Port B. And MOSI is the same as DI on port B. When you've configured port B for serial programming of the internal memories then the microcontroller is acting as a slave and the pins are referred to as MISO and MOSI. When you've configured port B for SPI communications with other devices for your application then the microcontroller could be a master or a slave. In this case the pins are referred to as DO and DI because only data direction is known and whether the microcontroller is a master or slave is application dependent.
To use the microcontroller as a master and communicate with a slave SPI device connect: