Trying to implement RS232 hardware handshaking between a PC Serial port and an Analog Devices Blackfin 533

Ahh the ever popular confusing with RS232 continues.

So the first thing I'm asking myself is if my dsp (the blackfin 533) is a DCE or DTE. I'm assuming it's a DTE for the time being.

So I figure that all I need to do is use a null modem cable that has the TX and RX lines crossed as well as the RTS and CTS lines. I figure I will just use two of the Blackfin's Programmable Flags to behave as RTS and CTS lines.

The confusion arises when I ask myself if the RTS signal from the PC's serial port is a signal that means Ready to Receive, or Request to Send. I've done a lot of reading online and some places say it's Ready to Receive, others mention Request to Send.

I'm working on the assumption that the RTS signal means Ready to Receive. In this case, all I would do is monitor that line on the DSP side until it's negated. When it's negated (a logic level "1" I believe), then I would make sure the DSP stops sending data out the UART. Conversely, I would use a programmable flag on the DSP to assert the PC Serial port's CTS line when the DSP is ready to receive data, and negate it when it wants the serial port on the PC to stop sending it data.

I just wonder if this is the correct thinking.

Reply to
reuvenkishon
Loading thread data ...

is

figure

PC's

Ready

assert

RS-232 is a big headache, until you try to use USB (as PC makers want to force us to)... then it starts looking very simple and user-friendly.

DCE/DTE is not a chip issue: the UART doesn't care if it's DCE or DTE, it only depends on the way the board is wired. PC RS-232 ports (if any) are all DTE.

To make things more fun, there are THREE types of connectors in use: DB-25 (Male IIRC, not used often in newer equipment), DB-9 Male AND Female. There are both "Null-Modem" cables (Rx/Tx crossed) and "straight" cables.

My suggestions:

  • If possible, send and recieve all data as human-readable ASCII data (e.g. - send numbers as strings, commands as human-readable names); it makes debugging much easier, especially if you have to debug in the field.

  • Forget about handshaking in hardware, use XON/XOFF protocol. That way you only have two signals to mess around with. The XON/XOFF protocol has provisions to support binary data if necessary, by using the DLE escape-sequences.

  • I'd recommend wiring your board as DTE, using a Male DB-9 connector with the same pinout used by PCs. If you use XON/XOFF, you may even save on H/W costs by eliminating RS-232 Tx/Rx buffers. There are many single-voltage chips available with any combination of drivers and receivers.

  • Find a cable that works, label it clearly AND KEEP IT SAFE FOREVER. If you don't have the cable when needed, you'll never know if your device had stopped working or you are just using the wrong cable. If you use DTE pinout, you'll need a null-modem cable.

Reply to
assaf_sarfati

The spec says it's Request to Send. The original, official usage for RTS/CTS is for controlling the direction of a half-duplex link:

When DTE want to transmit, it asserts RTS. DTE waits for RTS to be asserted. When DCE is ready to receive, it asserts CTS. DTE transmits data. When DTE is finished sending and is ready to receive, it deasserts RTS.

However, today RTS/CTS, it's often used as part of a full-duplex flow-control scheme where the DTE stops sending if CTS is off, and the DCE stops sending if RTS is off.

If you're talking to a PC that has RTS/CTS flow control enabled, that's probably correct.

--
Grant Edwards                   grante             Yow!  I was giving HAIR
                                  at               CUTS to th' SAUCER PEOPLE
 Click to see the full signature
Reply to
Grant Edwards

CTS

FWIW, there was sometimes a significant delay (tens/hundreds of millisceonds) between the DTE's assertion of RTS and the DCE's assertion of CTS due to the time required for the modem's tx carrier to come on and stabilize.

--
Grant Edwards                   grante             Yow!  WHOA!! I'm having
                                  at               a RELIGIOUS EXPERIENCE
 Click to see the full signature
Reply to
Grant Edwards

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.