CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

How to connect RS232 (DB9) connector to PIC16F690?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Guest








How to connect RS232 (DB9) connector to PIC16F690?
PostPosted: Tue Oct 16, 2007 9:38 am     Reply with quote

I have a PicKit2. Thanks!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 16, 2007 12:08 pm     Reply with quote

The PicKit with a 16F690 is really a very minimal board. It doesn't have
a MAX232 level shifter on it. It doesn't have any easy way to connect
to a PC serial port.

The schematic of the "Low Pin Count" board shows that it has very few
features. It has a few LEDs. The Port B pins are not available on the
header.
http://ww1.microchip.com/downloads/en/DeviceDoc/Low%20Pin%20Count%20User%20Guide%2051556a.pdf

You could create a software UART, and use the INVERT option. Then
connect the Rx pin of your soft UART (on the PIC) to pin 3 on the
PC's DB9 connector with a series resistor, as shown in this schematic:
http://www.instructables.com/files/orig/FVI/TR35/VW1EP27VUPP/FVITR35VW1EP27VUPP.gif

The Tx pin on the PIC (from a software UART) would go to pin 2 on the
DB9 connector. This is not shown on the schematic.
You must also have a ground connection between the PicKit board
and pin 5 on the DB-9 connector.

Pins C4 and C5 are free for use on that board. So connect pin 3 on
the DB9 through a 22K resistor to pin C5. Then connect pin 2 on the
DB9 with a wire to pin C4. Also connect pin 5 on the DB9 to GND,
which is pin 14 on the header. Make sure you understand the pin
number layout on the header connector and the DB9, and connect
everything to the right pins, or you might destroy the board.

Here's a test program.
Code:

#include <16F690.h>
#fuses INTRC_IO, NOWDT, NOBROWNOUT, PUT, NOMCLR
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C4, rcv=PIN_C5)

//================================
void main()
{
char c;

printf("Start \n\r");

while(1)
  {
   c = getc();
   putc(c);
  }

}
Guest








PostPosted: Tue Oct 16, 2007 1:12 pm     Reply with quote

I'm getting a MAX232 dip from inventory right now. I'm assuming it's easier with the MAX232. How would that be connected thanks!
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Tue Oct 16, 2007 1:45 pm     Reply with quote

Google the datasheet.

Follow the example schematic on the datasheet.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 16, 2007 1:47 pm     Reply with quote

Here's a schematic that shows how to connect a 16F690 to a MAX232
chip and to a DB9. The MAX232 and the DB9 will be attached to the
prototyping area on the board.
http://www.melabs.com/downloads/LABX20SC_06.pdf

You will need a "1 to 1" (also called "straight-through") serial cable
to connect between the DB9 for the board and the DB9 on the back
of your PC.

Note that the MAX232 requires 5 capacitors. Three of them are shown
below the MAX232 symbol in the schematic. If you have a MAX232A,
then you can use 0.1 uF capacitors instead of the 1.0 uF value.

The connections on the DB9 from pins 1 to 6 to 4, and from 7 to 8
really aren't needed. All you need are the connections going to
pins 2, 3, and 5.

With the MAX232, you should use the hardware UART on pins B7 and B5,
so the test program should now be this:
Code:
#include <16F690.h>
#fuses INTRC_IO, NOWDT, NOBROWNOUT, PUT, NOMCLR
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_B7, rcv=PIN_B5, ERRORS)

//=============================
void main()
{
char c;

printf("Start \n\r");

while(1)
  {
   c = getc();
   putc(c);
  }

}
Thomas82
Guest







PostPosted: Wed Oct 17, 2007 3:42 pm     Reply with quote

I have everything connected just like the schematic. I'm getting output in Hyperterminal, and I'm getting the LEDS to blink.

Unfortunately the output in hyperterminal looks like this:


ß ß ß ß ßß ß ß ß ß ß ß ß ß ß ß ß ß
ß ÷ ß ß ß ß ß ß ÷÷ ß ÷ß ß ß
ß ß ß ß ß ß ß ß ÷ ß ÷ ÷ ß ß
ß ß ß ß ß ß ß ß ß ß ß ß ß ß ß ß
ß ß ß ß ß ß ß ßß ß ß ß ß ß ß ß ß ß ÷ ß ÷
ß ß ß ß ÷ ß ß ß ß ß ÷ß ßß ß ß ß ß
÷ ß ß ß ß ß ß ßß ß ß ß ÷ ß ß÷ ß ß ß ÷ ß
ß÷ ß ß ÷ ß ß ßß ß ß ß ß ß ß
ß ßß ß ÷ ß ÷ ß ÷ß ÷ ß ß ß ß ß ß ÷ ß ß
ß ÷ ß ß ß ß ß ß ß ß÷ ß
ß ß ß ß ß ÷ ß ß ß ß ßß
ß ÷ ß ß ß ÷ ß ß ß ß ß ß ÷ ÷ ß ß
ß ß ÷ ß ÷ ß ß ÷ ÷ ß ß ß ß ß ß ß ß
ß ß ß ß ÷ ß ß ß ß ß
ß ß ÷ ß ß ÷ ß ß ß ß ß ß ß ÷ ß ß
ß ß ß ß ß ß ÷ß ÷ ß ß ÷ ß ß ß ß
ß ß ß ß ß ß ß ßß ÷ ß ßß ß ÷ ß ß
ß ß ÷ ß ß ÷ ÷ ß ÷ ß ÷ß ßß ß ß ß ß ß ß ß ß
ß ß ß ßß ß ß ß ß ß ß ß ß ÷ ß ß ß ßß
ß ß ÷ ß ß ÷ ß ß ÷ ß ÷ ß ß ÷ ß ÷ ß
ß ß ß ß ÷ ßß ß ß ÷ ß ß ß ß ß ÷

BTW THANKS for all the help so far!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 17, 2007 4:21 pm     Reply with quote

I tested it just now with compiler vs. 4.058 and it works OK.
I have a 3M breadboard with a 16F690 and a MAX232A on it,
and I programmed the PIC with an ICD2 from MPLAB.
It displays:
Quote:

Start
asdfghjkl

Etc., as I type in keys in a terminal window.

I suspect either your hardware is wrong, or maybe it's a problem
with your compiler. What's your compiler version ? It's listed at
the start of the .LST file, which will be in your project directory.
It's a 4-digit number such as 3.249, 4.013, 4.059, etc.
ThomasC



Joined: 09 Oct 2007
Posts: 62

View user's profile Send private message

PostPosted: Thu Oct 18, 2007 10:04 am     Reply with quote

It is version 4.059.
I just noticed two things. The caps in the diagram are polarized; the ones I installed are not polarized.

I did a search and found this neat gif that you posted earlier.
http://www.geocities.com/SiliconValley/Network/3656/c2c/rs232x.gif

Does this schematic apply to the to PIC16F690? I've also checked in the back of the manual like you said and it shows Vcc and hooked up to + and Gnd hooked to ground. I hooked them up appropriately and am trying it as we speak.

I'm also reading your old posts in this thread as we speak:
http://www.ccsinfo.com/forum/viewtopic.php?t=26898

Thanks this getting the ball rolling again while I'm at work. Smile
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 18, 2007 10:08 am     Reply with quote

That schematic can be used with the 16F690. The striped side of the
caps is the negative side.
Guest








PostPosted: Fri Oct 19, 2007 9:30 am     Reply with quote

Is it mandatory that the caps are polarized? All I have are non polarized caps?
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Fri Oct 19, 2007 10:16 am     Reply with quote

Non polarized caps are fine. Just don't use polarized caps the wrong way around.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Guest








PostPosted: Mon Oct 22, 2007 8:02 am     Reply with quote

Success! The hardware connections are correct. It was buggy code.

I put the printf commands after a "for" loop. It worked after I put the prinf commands before the "for" loop.

Now it will output "Start" and "asdf;lkajsdf" or whatever I type in. Thanks everyone.
Guest








PostPosted: Mon Oct 29, 2007 12:14 am     Reply with quote

Hi

Im new to all this and am trying to connect a pic16f690 to a max232. I can do the hardware side of things but writing the code is the bit i need help with. I am using a pickit2 with mplab7.6. Do i just copy the code given earlier and off it goes. If not can sombody give me the enitre code and instructions on how to enter it into mplab.

Thanks in advance
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 29, 2007 1:29 am     Reply with quote

Quote:
Do i just copy the code given earlier and off it goes.

Yes.

See this tutorial on how to setup MPLAB for use with CCS:
http://www.ccsinfo.com/faq.php?page=ccs_mplab6
Guest








PostPosted: Tue Oct 30, 2007 3:13 pm     Reply with quote

Thanks for that. Tried entering the code into mplab and compiling it and comes up with a build error saying pcm compiler isnt installed. Where do i find this compiler or should i change the compiler. How do i do this? Thanks very much
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group