Page 1 of 1

A Simple RS232 Serial Interface

Posted: Thu Apr 07, 2011 6:34 am
by ThePyroElectro
A Simple RS232 Serial Interface Tutorial

RS232 serial communication is widely used for transferring 8 bits of information at a time. The PIC gives us easy access to hardware that is capable of serial communication. This tutorial shows you how to build a simple, but effect RS232 communication interface.



Questions & Comments?

Re: A Simple RS232 Serial Interface

Posted: Sat Aug 25, 2012 4:57 am
by MAAASD
Thank you very much but i've one question
can i make this circuit and use it for my laptop even if it doesn't have an RS232 port?
can i use USB-RS232 converter?

Re: A Simple RS232 Serial Interface

Posted: Sat Aug 25, 2012 5:51 pm
by ThePyroElectro
MAAASD wrote:Thank you very much but i've one question
can i make this circuit and use it for my laptop even if it doesn't have an RS232 port?
can i use USB-RS232 converter?


Yes you can. But becareful, some USB-RS232 converters are not very good quality. FTDI chips seem to convert USB-RS232 pretty well.

Re: A Simple RS232 Serial Interface

Posted: Mon Oct 13, 2014 3:06 am
by Fayev
This was a very instructive tutorial, although I have a question, why do you set TRIS for RX an TX both as inputs? Is it because the PIC is working on slave mode?

I'm working on a project now which uses I2C (your tutorial also very helpful! :D) to read time from a RTC, and then send it via serial. I'm using USART default pins, but the serial communication didn't work until I set the TRIS as inputs as you did.

Now I have one more question, is it possible to use both I2C and USART in the same pic? I had them working separately, but now I've put them together they won't work at all.

I understand the BRG registers are different for each one so there shouldn't be any baud problem... Is there anything I'm missing here?

Thank you for your tutorials, and for your time!

Re: A Simple RS232 Serial Interface

Posted: Mon Oct 13, 2014 11:07 pm
by Fayev
Ok, problem with I2C and USART solved, nothing to do with bauds or registers... It was just the pin from the pic not making a good contact with the PCF8583.

Question no. 1 still's on though.

Thanks!

Re: A Simple RS232 Serial Interface

Posted: Mon Nov 03, 2014 12:12 am
by ThePyroElectro
Fayev wrote:Ok, problem with I2C and USART solved, nothing to do with bauds or registers... It was just the pin from the pic not making a good contact with the PCF8583.

Question no. 1 still's on though.

Thanks!


Hi,

If you use the API functions for using the serial interface, I believe the TRIS setting does not matter. I can understand why setting them the same would be confusing.

The C18 serial functions change the TRIS setting when you first use them to setup the interface properties.

Re: A Simple RS232 Serial Interface

Posted: Mon Nov 24, 2014 8:17 pm
by Fayev
Oh I see, so that's how API functions work... Thank you for your reply!

Re: A Simple RS232 Serial Interface

Posted: Thu Oct 22, 2015 11:15 pm
by bidbirdlin
Hi,

It is very great tutorial and give me some rough idea. I am newbie to those controller and PIC program. I didn't see you post those steps regarding how to execute your software part. Can you guide me through the steps? like how to implement .c file? Should I compile .c file? what program to run when you start to hit number key, 1,2,3...etc?

Lenny

Re: A Simple RS232 Serial Interface

Posted: Thu Nov 05, 2015 1:55 pm
by ThePyroElectro
bidbirdlin wrote:Hi,

It is very great tutorial and give me some rough idea. I am newbie to those controller and PIC program. I didn't see you post those steps regarding how to execute your software part. Can you guide me through the steps? like how to implement .c file? Should I compile .c file? what program to run when you start to hit number key, 1,2,3...etc?

Lenny


Hi,

I usually assume that people understand this part of the program process because it becomes rather redundant to repeat it in every article, so I wrote some articles about that process and I usually point people to them.

This RS232 article itsself describes how to use the PIC with their antiquated 'C18' compiler which still works and is still supported by Microchip, but they're trying to move beyond it. So if you're interested in following that article and using that code, these two articles take you through the process of using the MPLAB IDE:

http://www.pyroelectro.com/tutorials/pic_microcontroller/index.html
http://www.pyroelectro.com/tutorials/program_pic/index.html

The modern IDE is called MPLABX and the modern compiler is called XC8. Here is an example of how you use both:

http://www.pyroelectro.com/tutorials/pickit3_mplabx/