View previous topic :: View next topic |
Author |
Message |
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
#use rs232 ONLY TX |
Posted: Fri Sep 24, 2021 5:40 am |
|
|
Hello friends,
I am using a PIC24FJ16GA002 and I need the UART only for sending debug messages to the PC. I do not need to receive anything.
Is there a way to enable only the TX pin?
If I do not "pin_select" the U1RX I get error: "USE parameter value is out of range No UART defined, May need #PIN_SELECT"
Thanks! _________________ George. |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1346
|
|
Posted: Fri Sep 24, 2021 5:55 am |
|
|
if it is just for output, you can use a software serial port:
Code: |
#use rs232(FORCE_SW,baud=9600,DISABLE_INTS, XMIT=PIN_B2)
|
Another thing you could try if you want to use a hardware serial port is set both pin_selects for TX and RX to the same pin.
Code: |
#pin_select U1RX=PIN_B2
#pin_select U1TX=PIN_B2
#use rs232(UART1,baud=9600,ERRORS)
|
I think as long as you don't call getc it should be fine, but I've never tried it. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Fri Sep 24, 2021 6:18 am |
|
|
I agree, use software serial TX only.
Simple and easy AND it keeps the HW serial available for future use( like 3 days from now, when client 'needs' a new feature.....)
Also ..any I/O pin can be used.
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19505
|
|
Posted: Fri Sep 24, 2021 6:29 am |
|
|
Key is what is allowed on the UART.
You can turn off the TX part, but you can't separately turn off the RX.
So the standard way to get RX only, it to setup both, and then manually
turn off the TX.
For TX only this isn't available. However there is a very simple solution.
Just #pin select the RX pin to the same pin as the TX.
This way the RX will receive every character you send. If you don't have
any code to handle the RX, then these will just be ignored. |
|
|
|