A Simple RS232 Serial Interface

Questions and Comments on All Tutorials

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

A Simple RS232 Serial Interface

Postby ThePyroElectro » Thu Apr 07, 2011 6:34 am

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?

MAAASD
Newbie Pyro
Posts: 2
Joined: Sat Aug 25, 2012 4:53 am

Re: A Simple RS232 Serial Interface

Postby MAAASD » Sat Aug 25, 2012 4:57 am

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?

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Re: A Simple RS232 Serial Interface

Postby ThePyroElectro » Sat Aug 25, 2012 5:51 pm

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.

Fayev
Newbie Pyro
Posts: 7
Joined: Mon Apr 21, 2014 1:34 pm

Re: A Simple RS232 Serial Interface

Postby Fayev » Mon Oct 13, 2014 3:06 am

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!

Fayev
Newbie Pyro
Posts: 7
Joined: Mon Apr 21, 2014 1:34 pm

Re: A Simple RS232 Serial Interface

Postby Fayev » Mon Oct 13, 2014 11:07 pm

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!

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Re: A Simple RS232 Serial Interface

Postby ThePyroElectro » Mon Nov 03, 2014 12:12 am

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.

Fayev
Newbie Pyro
Posts: 7
Joined: Mon Apr 21, 2014 1:34 pm

Re: A Simple RS232 Serial Interface

Postby Fayev » Mon Nov 24, 2014 8:17 pm

Oh I see, so that's how API functions work... Thank you for your reply!

bidbirdlin
Newbie Pyro
Posts: 7
Joined: Thu Oct 22, 2015 11:08 pm

Re: A Simple RS232 Serial Interface

Postby bidbirdlin » Thu Oct 22, 2015 11:15 pm

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

ThePyroElectro
PyroElectro Admin
Posts: 1181
Joined: Mon Nov 12, 2007 9:24 pm
Location: Earth
Contact:

Re: A Simple RS232 Serial Interface

Postby ThePyroElectro » Thu Nov 05, 2015 1:55 pm

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/


Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 4 guests