RS232 Functionality with a Microchip
One of the most frustrating things about working with IC's is that when they don't work you have almost no idea why. In the past I've tried to wire up LED Segments to help with this,
but that can be a tedious task in itself. Lately I've been looking into LogicAnalyzers and Oscilloscopes. I purchased a pretty nice LogicAnalyzer. But the Oscilloscopes are a little pricey for my budget. So I decided to make my own.
It won't be a true oscilloscope mind you, but it will serve for my purposes. My plan is to simply log the values from the ADC built into the Microchip PIC16F690 's that I use. And the first step to this is to setup a RS232 connection between my
PIC and my computer. So below are my exploits.
First I want to give credit to this amazing article that I found.
This guy was detailed enough in his article to walk me through all of the tricky stuff. (Although looking back it was a lot simpler than I had originally thought.)
Even though he walks you through setting up one way communication (from the PIC to your computer) without using a RS232 driver, I had already purchased a lot of Maxim MAX232ACPE Drivers a few years back.
Only I never knew exactly how they worked. Well here's a diagram stolen directly from the datasheets.
So the MAX232A needs (5) .1uF capacitors. I used ceramic capacitors so I didn't have to worry about polarity.
(And let me say the only purpose of the MAX232 and the capacitors is to convert the PIC TTL signal (0V/5V) into a -10V/+10V which is needed to conform to the RS232 standard. I didn't understand that until recently.)
Here are a couple pictures of my breadboard setup.
With the code from the code project website I connected RB7 from the PIC to pin 11 on the RS232 Driver. And then I ran pin 14 from the RS232 driver to the serial DB9 connector(Pin 2).
Here's the code that I used.
To add the RS232 Driver I had to comment out Line 25 of the ASM code (bsf BAUDCTL, SCKP).
The only really big headache that I ran into was that I didn't have the ground hooked up for the RS232 driver for the longest time...and couldn't figure out why it wasn't working. The schematic for the driver
almost has PIN 15 hidden. It's connected at the bottom of the diagram, and I simply overlooked it.