My project involves a PIC communicating over USB and RS-232 channels, which are then multiplexed to 1 UART by means of a dual SPDT analog switch. As such, the PIC has to know which ports are physically connected, in order to select either the USB port or the RS232 port.
How would I go about doing this? For RS-232, I could set an externan interrupt for the DTR line, but in my industry field, only Tx, Rx and Gnd are used.
For USB, I could potentially use Vbus to detect the presence, but overcurrent is possible
Or would it be more feasible to monitor the impedance of the usb differential lines and the rs232 tx rx lines, like in the audio jack sensing circuits?