SP.710, Spring 2001: "Intro to Microcontrollers"

PIC to PC serial communications

For user interface, data transfer, and debugging purposes, it is often useful to be able to connect a PIC-based circuit to a computer and transfer data (such as text) back and forth. For example:

To send data to and from a computer over the serial port, you need a combination of hardware and software. The software deals with sending and receiving a pattern of "ones" and "zeros" (5 volts or 0 volts) and converting this to and from some useful format, like ASCII/text. In PIC C, the commands KBHIT, PUTC, GETC, and PRINTF, and #USE RS232 are useful commands for doing serial communications (look them up in the manual).

The hardware deals with making sure the voltages are at the right levels (computer serial ports use +12 and -12 volts ("RS-232 levels") instead of 0 and 5 volts ("TTL/CMOS levels"). In your PIC circuit, this hardware voltage conversion is handled by an external chip, the MAX233 "RS232 Driver/Receiver".


  1. Using the attached data sheet, wire up the MAX233 chip to your PIC circuit. This is intentionally vague, so ask if you have questions. As a hint, you can ignore T2IN, T2OUT, R2IN, and R2OUT.
  2. Hook up a DB-9 serial connector to the RS-232 side of the MAX233 chip. You only need to use three of the pins on the connector: Pin 5 should connect to ground, Pin 2 is Receive for the computer (so should be Transmit from the PIC), and Pin 3 is Transmit for the computer.
  3. Write a PIC program that prints a messages to the serial port from the PIC. Test it.
    [ To send and receive data on your laptop/PC, run a terminal program such as Hyperterm, and set up your connection with No parity, 8 data bits, 1 stop bit, and no handshaking. ]
  4. Write a PIC program that waits for a letter to be pressed on the keyboard, then prints some message of your choosing based on the letter ("I see you pressed the letter A", or "You pressed F. The next letter in the alphabet is G", "You pressed a vowel", etc...)
  5. Continue with the Simon project.

Other references:

full MAX233 (and family) datasheet available at:

(maxdavis@mit.edu, 2/21/2001)