Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Serial Communication PIC16F88 with PC using SPI or RS232

Status
Not open for further replies.

bilal_oct

Full Member level 1
Joined
Aug 8, 2008
Messages
96
Helped
8
Reputation
16
Reaction score
5
Trophy points
1,288
Activity points
1,950
Is it possible to interface PIC16F88 with computer serial port directly ? using SPI or RS232 protocol.

Which one is more reliable and faster serial communication SPI or RS232 ?
 

Short Answer:
SPI - No.
RS232 - yes but you need to use the UART in the PIC16F88.

Longer answer:
The SPI protocol involves an exchange of values between to devices (typically referred to as the master and the slave) and also the master supplies a clock signal to indicate when the master's data is stable (therefore the slave can sample it) and vice versa. Because the master and the slave must agree on which clock transition to use, both sides need to be set up appropriately beforehand.
This arrangement makes it unsuitable to communicate with a PC which typically does not have an external SPI port.
It also follows that talking about which is more reliable and faster does not come into the picture as the SPI option is just not possible in communication with a PC (unless you add additional hardware etc.).

For the RS232 communication, many older PCs will have an RS232 port but more modern PCs will have replaced these on the assumption that communication will be via an USB connection. If that is the case for your PC, then you will need a 'USB to Serial' interface chip - there are many around including the FTDI devices. (Just be aware that often such devices operate on the same voltages as the PIC and not the standard RS232 voltages.)
You will also need to realise that RS232 is an electrical protocol as well as one that defines the serial data format (start bit, number of bits, number of stop bits, parity bit etc.). Typically the RS232 signal uses between +3 and +12 volts to indicate an "on" or '0' bit state, and -3 to -12 volts to indicate an "off" or '1' state (and yes, the '0' and '1' are inverted to what you might normally consider a binary value). If you tried to connect the RS232 lines directly to a PIC, you will probably destroy the Rx line (where the PC will drive voltages that are way beyond what the PIC is designed to accept) and the PC will probably not understand the Tx signal as it will never be driven low (i.e. negative) enough for it to register a '1'.
Therefore you need an interface chip to convert the RS232 level voltages to the 0 to 3v3 (or 5V) voltages for the PIC.
Once you have the electrical interface sorted out, you can then use the AUSART on the PIC16F88 to receive and transmit the values as you require. Of course you will also need to set both the PIC and the PC to use the same BAUD rate, number of bits, parity and other settings.
Susan
 
I would like to use RS232 protocol. I am wondering if I use the following interface chip between PC and PIC16F88, would it work ?

MAXIM
MAX232CPE
1240
 

hello,

if your speed is <=38400 bauds , you can use this**broken link removed** or other soluces..
 

My vote is on the MAX232 too. It's third party sourced so you don't have to rely on Maxim to get around to making some, and is pretty much the industry standard. It has its own voltage converters for the RS232 lines and level shifts to/from TTL.

You may get away with using a couple of BC548s as buffers/inverters. That worked with my desktop machine, but the USB - serial converter for the laptop required the interface chip.
 
It's a shame PC users dont seem to use the Firewire ports like Apple users (IEEE 1394)

But you dont likely have a need for this bandwidth so use RS-232 with UART and parity.

IEEE1394 Requires Microchip ...EQCO400T



 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top