|
|
View previous topic :: View next topic |
Author |
Message |
PICAlison
Joined: 11 Jun 2021 Posts: 10
|
RS232 handshaking problem (CTS not going low) |
Posted: Thu Jul 22, 2021 9:12 am |
|
|
I can't seem to get the handshaking working on my PIC24FJ1024GB610.
I need hardware handshaking, RTS & CTS. The CTS line never goes low.
Must be doing something silly wrong. Any ideas anyone?
Code: | #pin_select U1TX = PIN_B14
#pin_select U1RX = PIN_B15
#define PIN_UART1_RTS PIN_A10
#define PIN_UART1_CTS PIN_C2
#ifndef __UART_BAUD__
#define __UART_BAUD__ 115200
#endif
#use rs232(baud=__UART_BAUD__, FLOW_CONTROL_MODE, UART1, RECEIVE_BUFFER=10, TRANSMIT_BUFFER=10, xmit=PIN_B14, rcv=PIN_B15, RTS=PIN_UART1_RTS, CTS=PIN_UART1_CTS, parity=N, bits=8, stop=1, errors)
|
|
|
|
gaugeguy
Joined: 05 Apr 2011 Posts: 303
|
|
Posted: Thu Jul 22, 2021 9:54 am |
|
|
You need to use #pin_select for the control lines also, not just the RX/TX pins. |
|
|
gaugeguy
Joined: 05 Apr 2011 Posts: 303
|
|
Posted: Thu Jul 22, 2021 9:59 am |
|
|
Also, from the PIC's point of view CTS is an input so would need to be driven low by the device it is connected to. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Fri Jul 23, 2021 12:45 am |
|
|
and (of course), the data sheet is your friend here.
If you look at the diagram in the data sheet for the UART, the CTS line
has it's arrowhead pointing inwards to the chip hardware. Just like the RX
line. The ones that have their arrows pointing outwards are the TX, and the
RTS.
This is where 'nomenclature' is vital when dealing with RS232.
A DTE device versus a DCE device.
On a DCE device, the transmit line is an input!.
You must always identify when you talk about RS232 connections, whether
your device is DCE or DTE.
A null modem provides the wiring to connect a DTE device to another
DTE device (or DCE to DCE). Swapping TX with RX, DTR with DSR, and
RTS with CTS.
The PIC UART nomenclature is for a DTE device, so the signals need to
be swapped over to talk to another DTE device. So the PIC's TX has to
connect to a PC RX, and the PIC's RTS to the PC CTS. If instead you are
connecting to a DCE device (modem), then the connections would be 1:1. |
|
|
PICAlison
Joined: 11 Jun 2021 Posts: 10
|
|
Posted: Mon Jul 26, 2021 6:43 am |
|
|
Thanks everyone, my fault, RTS & CTS not wired up right! |
|
|
|
|
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
|