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

RS232 handshaking problem (CTS not going low)

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



Joined: 11 Jun 2021
Posts: 10

View user's profile Send private message

RS232 handshaking problem (CTS not going low)
PostPosted: Thu Jul 22, 2021 9:12 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jul 22, 2021 9:54 am     Reply with quote

You need to use #pin_select for the control lines also, not just the RX/TX pins.
gaugeguy



Joined: 05 Apr 2011
Posts: 303

View user's profile Send private message

PostPosted: Thu Jul 22, 2021 9:59 am     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Jul 23, 2021 12:45 am     Reply with quote

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

View user's profile Send private message

PostPosted: Mon Jul 26, 2021 6:43 am     Reply with quote

Thanks everyone, my fault, RTS & CTS not wired up right! Embarassed
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