I could use some help thinking through what options I may have, if any, for embedding a CP2102 USB-to-serial converter into a MSP430 microprocessor project, so that updating the flash could be done with just a USB cable. The processor would be a MSP430G2231.
This function is built into Arduino boards, which have more powerful processors with dedicated pins for all the USB and serial stuff. But the2231 only has 14 pins.
The idea is to embed a CP2102 module like this one:
on the project board, with its USB socket accessible through a port in the case.99.9% of the time, the CP2102 will not be connected to USB, and will therefore be powered down. The problem is that the serial input and output pins of the CP2102 will be permanently connected to processor pins normally used for other things. I had hoped that when powered down, the CP2102 would go all nice and tristated, but alas, that's not the case. I guess it's mostly the protection diodes, but when the CP2102 is powered down, its 3.3V regulated output pin will sink 9 ma of current when 3.5V is applied to it from the project. TXD and DTR sink the same, but RXD will sink over 12 ma. I had expected to need a diode for the 3.3V supply, but the other pins were a disappointment. Anyway, any processor pin directly connected to these CP I/O pins will be effectively grounded, at least down to a diode drop above ground.
For a moment I thought I had a very simple cure, which was inserting a diode in the CP2102's ground connection to the project ground. That would indeed prevent all that current from flowing backwards. But that still leaves the problem that the processor pins connected to TDX and RXD are still connected to each other though those two pins and all the CP2102 circuitry behind them, and the effective resistance between them measures fairly low.
So I've tentatively concluded that all four lines need to have diodes to prevent any interference with the project circuit when USB is not connected. Then I would need to enable the processor's built-in pulldown resistors for the processor pins connected to DTR and TXD, and add a physical pullup resistor on the CP2102 side of the diode on the RXD pin since the processor output pin will only be able to pull it down when transmitting because of the diode.
And leaving the CP2102 powered up would use up way too much current. The whole point of the MSP430 stuff is micropower.
Well I'm just curious whether there's something I haven't considered that would be a more elegant solution. Of course the typical solution for these MSP430 chips is to have a female header in the circuit, and only connect the an external USB adapter when it's time to flash. But I would rather embed the adapter if I can get away with it. At this point I'm looking at the adapter module, four diodes, and a resistor, which would certainly be fine if that's the best I can do. But if anyone has a better solution, please let me know. I've got all the software written for both ends to implement this bootstrap loader protocol, but should have considered the hardware earlier. But if I can get it all to work, I plan to post it all on Github in case someone else might make use of it.