View previous topic :: View next topic |
Author |
Message |
jlucas
Joined: 08 May 2011 Posts: 41 Location: Carthage, MO
|
Proper syntax for #use rs232 function |
Posted: Sun May 08, 2011 7:43 pm |
|
|
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
|
|
Posted: Sun May 08, 2011 7:53 pm |
|
|
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
|
|
Posted: Sun May 08, 2011 7:55 pm |
|
|
Thanks for the quick response. This sounds almost too good to be true, but I'll certainly give it a try! _________________ Always remember, things are never so bad that they can't get worse. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9249 Location: Greensville,Ontario
|
|
Posted: Mon May 09, 2011 5:29 am |
|
|
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
|
|
Posted: Mon May 09, 2011 6:15 am |
|
|
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
|
|
|
jlucas
Joined: 08 May 2011 Posts: 41 Location: Carthage, MO
|
|
Posted: Mon May 09, 2011 11:57 am |
|
|
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
|
|
Posted: Mon May 09, 2011 12:13 pm |
|
|
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
|
|
Posted: Mon May 09, 2011 12:31 pm |
|
|
Thanks again! _________________ Always remember, things are never so bad that they can't get worse. |
|
|
|