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 CCS Technical Support

max232 tx / rx

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nina



Joined: 20 Apr 2007
Posts: 111

View user's profile Send private message Send e-mail

max232 tx / rx
PostPosted: Sun Jun 20, 2010 8:40 pm     Reply with quote

hi everybody....

Scenario is:

pic----max232----pc

Is it mandatory use ports tx and rx from pic to connect to max232?
Or can I specify another port as tx and rx using:
#use rs232(baud=9600, xmit=PIN_B4, rcv=PIN_B7, stream = name)

What does it mean stream? How does it work? Could you give me a example where can I use it?

thank you

nina
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Mon Jun 21, 2010 12:29 am     Reply with quote

No the hardware UART pins rx tx aren't mandatory since if you don't use them the CCS compiler will generate a software emulation on the alternative pins.
The max232 doesn't care which pins it is connected to.
Now using the hardware pins has very strong advantages since it can be interrupt driven. The software emulation of the uart is constraining in that your code must always read the software Rx pin in a tight loop so as to not miss any character.
STREAM has its best advantage when there is more than one USE RS232 statement since it labels each one. It is of value even when there is only one use rs232 statement since it can clarify the code and make it more obvious. getc(name)
trirath



Joined: 14 Jun 2010
Posts: 20
Location: Pathunthanee Thailand

View user's profile Send private message

PostPosted: Mon Jun 21, 2010 1:51 am     Reply with quote

Just for your advantage please you see CCS Example SISR.C
which used receive msg with RDA Interrupt you can change this RDA into RB0 Interrupt (for test) instead and assign adding stream Name you want(Also PIN RX,TX need to be changed too).

And also need change putc(data); into fputc(STREAM NAME,data)

In actually, even if you use existing uart of PIC as example you can add stream name too. It have advantage in case of you need have more than 1 uart in a same PIC for assign which way you want to sent or receive.

Thank you
nina



Joined: 20 Apr 2007
Posts: 111

View user's profile Send private message Send e-mail

tx/rx
PostPosted: Mon Jun 21, 2010 6:22 am     Reply with quote

thank you very much for all explanation...
16f628 just has 1 tx and 1 rx.

If i want use another pins like RB2 (as tx) , RB3 (as rx) and use them with int_RDA, do I have to use max 232 connect to RB2 and RB3 to read values coming or going?

Tks

Nina
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Mon Jun 21, 2010 7:17 am     Reply with quote

You can't. The serial interrupt uses the dedicated Tx and Rx pins (C6 and C7). If you are using other pins for tx and rx then you have to code them in software. It's not difficult but there is no buffering capability and you have to bit-bang to get the bits.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jun 21, 2010 2:29 pm     Reply with quote

Yes, the CCS compiler can generate a software UART for you, but:
- It does not support the interrupts.
- Is sensitive for timing errors (from timer interrupts, etc) for both the Tx and Rx.
- Only supports half duplex (can not send and receive at the same time).
- Requires (a lot) more processing power.
- Maximum baudrate of about 28k8 on a 16MHz PIC18.
- Can not buffer data in the background.

If your chip has a hardware UART, then use it. The only good reason for wanting to use a software UART on the other pins is when you need more than 1 UART. All other reasons I can think of are to do with a bad design.
Save yourself a lot of time and use the hardware UART. The software UART has limitations that will cost you a lot of time in the future (I speak from personal experience).
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Mon Jun 21, 2010 2:38 pm     Reply with quote

The best thing to do is to become very familiar with the data sheet on your PIC. Look it over multiple times and study the sections that you will be dealing with even more. All Interrupts use built-in hardware that, if it gets it's data from the outside world, is tied to a particular pin. If you want to receive data via RS232 and use the interrupt then you _must_ use the pins that are specified in the data sheet.

Ronald
nina



Joined: 20 Apr 2007
Posts: 111

View user's profile Send private message Send e-mail

rs/tx
PostPosted: Tue Jun 22, 2010 4:36 am     Reply with quote

Thank you everybody for all explanation...

The reason of my question is because I got RF modules (simple and cheap) to interface with PC and PIC and another PIC (receiver). So it will comunicate with COM_PC and COM_PIC.
I have seen those RF modules with linear output and digital output (receiver) and data input and rf output (transmiter). What does it mean those pins?
Which one do I need connect at TX and RX?

Thank you again.

Nina
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Tue Jun 22, 2010 10:00 am     Reply with quote

nina wrote:
I have seen those RF modules with linear output and digital output (receiver) and data input and rf output (transmiter). What does it mean those pins?
You need to work with the digital pins to get/send data. On some chips the linear pin gives analog signal strength.


nina wrote:
Which one do I need connect at TX and RX?
Depends on which device is the sender and which is the receiver. Connect the devices like this:

(sender's TX pin)-->(data pin of TX module) ~ ~ RF ~ ~ (data pin of RX module)-->(RX pin of receiver)

Rohit
nina



Joined: 20 Apr 2007
Posts: 111

View user's profile Send private message Send e-mail

tx/rx
PostPosted: Tue Jun 22, 2010 7:22 pm     Reply with quote

Rohit

Could you give an example where can I use linear pin?

tks

nina
Rohit de Sa



Joined: 09 Nov 2007
Posts: 282
Location: India

View user's profile Send private message Visit poster's website

PostPosted: Wed Jun 23, 2010 10:05 pm     Reply with quote

nina wrote:
Could you give an example where can I use linear pin?
I'm sorry, I haven't ever used this functionality before. Maybe someone else can help. Here's what I got after a bit of googling:

Quote:
RSSI / Carrier Detect (pin 3) The Received Signal Strength Indicator provides a DC output voltage proportional to the RF input signal. The amplitude of the RSSI voltage increases with increasing RF signal strength. A simple transistor interface can yield a carrier detect logic output.


Something similar is written in the datasheet for a Parallax RF module http://www.active-robots.com/products/parallax/datasheets/communication/27982-433%20MHzRFTransceiver-v1.0.pdf

Rohit
trirath



Joined: 14 Jun 2010
Posts: 20
Location: Pathunthanee Thailand

View user's profile Send private message

PostPosted: Sat Jun 26, 2010 7:28 pm     Reply with quote

visit http://www.silaresearch.com/source.php (Thai) choose PKIT-5R for receiver and PKIT-5T for transmitter.
There are free source code that have advantage for this even if use old version CCS.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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