Page 1 of 1
GSM RTS CTS Port selection
Posted: Tue Dec 06, 2011 9:28 am
by cruzxia
Hi
Is possible to modify the PIC_GSM.c so that the RTS and CTS ports can be selected. (Like in the PIC_RS232.c you can select different ports/pins for the RTS & CTS).
At present you can select the pin number of the UART port for RTS and CTS, but you cannot change it from the UART port (C in my case)
The reason is that on the port C I need to use the T1OSC (2 pins) , and the SPI (3 pins) and UART (2 Pins). This only leaves one spare IO on Port C, so I will have to move RTS & CTS to Port A or B
Regards
Andrew
Re: GSM RTS CTS Port selection
Posted: Tue Dec 06, 2011 10:59 am
by Gary Freegard
Hi Andrew
If you look at the datasheet for the Pic you are using, you will find that the hardware UART (RS232) are wired to these pins. The only way to use other pins is to use software based UART, see link.
http://www.datadog.com/software_uart.pdf
Hope this helps
Gary
Re: GSM RTS CTS Port selection
Posted: Tue Dec 06, 2011 11:20 am
by Steve
To change the CTS and RTS pins, you can edit the C code file for the GSM component (in the "components" directory of Flowcode). Basically, you will need to search for all occurrences of "GSM_232_RTS" and "GSM_232_CTS" and change these lines accordingly.
For example, the line:
Code: Select all
clear_bit(MX_UART_TRIS, GSM_232_RTS); //RTS is an output
will need to become:
Code: Select all
clear_bit(<tris register for RTS>, GSM_232_RTS); //RTS is an output
To make this easier, you may want to set up a few defines for the PORT/TRIS for the CTS and RTS pins in this C code file. This way, you will only need to alter one line if you change your mind about which port you are using.
Note that the following code will probably need to be removed too:
Code: Select all
#ifdef GSM_232_HARDWARE
#if(GSM_232_RTS == MX_UART_TX)
#error RTS is set to TX pin
#endif
#if(GSM_232_CTS == MX_UART_TX)
#error CTS is set to TX pin
#endif
#if(GSM_232_RTS == MX_UART_RX)
#error RTS is set to RX pin
#endif
#if(GSM_232_CTS == MX_UART_RX)
#error CTS is set to RX pin
#endif
#endif
But looking at the code for this component, it seems that CTS is not used anyway.
Re: GSM RTS CTS Port selection
Posted: Tue Dec 06, 2011 12:58 pm
by cruzxia
Thanks for the replies.
I will setup some custom code to rearrange the ports as described, or remove the CTS from the C code and use the last remaining pin on port C for the RTS
Regards
Andrew