I am using a PIC18F2550 to control a H Bridge, and I am using several input signals, such as RS-232, I2C and Analog 0-5V to make the final PWM output for the H bridge. I have a problem with PCB space, so I am joining all the input signals in 4 pins, since they will never be used together: Vcc, GND, S1 and S2. S1 will be RS-232 Tx connected to the I2C SDA, and S2 will be RS-232 Rx connected to the I2C SCL and the Analog input. This way, since the user will select which kind of control he wants before using the system, I can save some space. Just to make it clear: The user will select one kind of input (RS-232 for example), and all the other inputs connected to this PIC pin will become a disabled input pin so to not interfere with the communication.
Since I have an analog input (were if the user send 0V the PWM will be 0% and 5V it will be 100%), I wanted to add a pulldown 100K resistor to make it safer in case there is nothing connected, because this is an analog control, so in case the connection is lost, the analog pin could read some voltage and the motor could go nuts. But since I have a I2C connection in the same pin, is this possible? I think it isnt because the I2C needs a pullup, and this will make a voltage divider, right?
Does anyone have a better idea, about a way to make it read 0V in case there is nothing connected in the analog mode, and still have the option to use the pins for I2C or maybe SPI in the future too? Thanks!
