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

Proper syntax for #use rs232 function

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



Joined: 08 May 2011
Posts: 41
Location: Carthage, MO

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

Proper syntax for #use rs232 function
PostPosted: Sun May 08, 2011 7:43 pm     Reply with quote

This question is so simple that it seems no one has even had to ask it before. I'm trying to send 8-bit data from a PIC 18F4520 to a Laird/Aerocomm AC4790 RF transceiver module at 57,600 baud. The default state of both the send and receive pins is HIGH. The AC4790 module requires a low start bit, then 8 data bits, then a low stop bit. It sounds pretty straightforward, but I've searched the forum for about 3 hours, and I can't find the answer.

If I had designed this function, what I want to do would look like this:

Code:
#use rs232(baud=57600, xmit=PIN_D4, rcv=PIN_C2, start=0, bits=8, stop=0)


I know that this syntax is incorrect since there is no such option as "start." However, I believe my pidgin syntax makes it pretty clear what I'm trying to do. Could some kind soul please provide me with a line of code that will work?

Thanks in advance,

Jim
_________________
Always remember, things are never so bad that they can't get worse.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 08, 2011 7:53 pm     Reply with quote

Quote:

The AC4790 module requires a low start bit, then 8 data bits, then a low
stop bit.

#use rs232() does this by default. You don't have to do anything extra
to get this.
jlucas



Joined: 08 May 2011
Posts: 41
Location: Carthage, MO

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

PostPosted: Sun May 08, 2011 7:55 pm     Reply with quote

Thanks for the quick response. This sounds almost too good to be true, but I'll certainly give it a try! Very Happy
_________________
Always remember, things are never so bad that they can't get worse.
temtronic



Joined: 01 Jul 2010
Posts: 9178
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon May 09, 2011 5:29 am     Reply with quote

Also be aware that USE RS232(...) requires a MAX232 or equal by default.

And.. add the 'errors' option to it as well.
SherpaDoug



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

View user's profile Send private message

PostPosted: Mon May 09, 2011 6:15 am     Reply with quote

If you use a software UART there is the "invert" option.
_________________
The search for better is endless. Instead simply find very good and get the job done.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 09, 2011 11:50 am     Reply with quote

The AC4790 chip uses a direct, non-inverted, TTL-level connection to the PIC.
It doesn't need a Max232 chip and he doesn't need the INVERT option.

http://www.lairdtech.com/Products/Wireless-M2M-and-Telematics-Solutions/Proprietary-Radio-Modules/DataSheets/AC4790-0209/

http://www.lairdtech.com/DownloadAsset.aspx?id=2548

Also, he is using a software UART (since he's using pins D4 and C2) so
the ERRORS directive doesn't do anything. It's ignored by the compiler.

He didn't give the exact dash number of the AC4790 that he's using, and
different versions can run at 5v or 3.3v. So depending upon the Vdd
voltage of the PIC, he could have an issue with the logic voltage levels.
jlucas



Joined: 08 May 2011
Posts: 41
Location: Carthage, MO

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

PostPosted: Mon May 09, 2011 11:57 am     Reply with quote

Embarassed Oops! I made a mistake in my post. The start bit is low, but the stop bit is high. If a low stop bit is the default, does that mean I need this?
Code:
#use rs232(baud=57600, xmit=PIN_A5, rcv=PIN_B3, bits=8, stop=1)

Will that still give me a low start bit if the default state of the line is high?

I'm using the AC4570-200-01 which runs on +5V. I checked the voltage output from the chip, and it's good.

Thanks again.
_________________
Always remember, things are never so bad that they can't get worse.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon May 09, 2011 12:13 pm     Reply with quote

CCS uses the standard signaling methods. The AC4790 expects the
standard methods. You don't have to do anything.

Also, look on page 18 of the AC4790 manual. It shows the Stop bit is
at a high level, which is the standard.

And "Stop=1" just tells the PIC to transmit 1 Stop bit (it could be set to
send 2 stop bits).
jlucas



Joined: 08 May 2011
Posts: 41
Location: Carthage, MO

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

PostPosted: Mon May 09, 2011 12:31 pm     Reply with quote

Thanks again! Wink
_________________
Always remember, things are never so bad that they can't get worse.
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