With H11L1 I managed to get away with about 5mA through the LED
The H11L1 is guaranteed to need no more than 1.6 mA.
Unless you want a lower propagation delay. Went with 5mA so the LED's parasitic capacitance is charged/discharged faster and it was actually less than 5mA because the LED had a resistor in parallel, didn't do that many measurements, was in a hurry. The aim was to match propagation delays.
[…] good up to 230.4k BAUD. I'm currently planning to use TLP118 optos because of their smaller form factor.
Do you really need 20,000,000 baud? The TLP2361 (15 Mbaud) would work with 1.6 mA, too.
Too bad I can't get that from the main distributor I use, found it on Mouser but shipping is 20 euros compared to TME which ships for less than 5.
They do have the TLP2362 which is the cheapest in that package but it needs more drive current.
I always use a driver for LEDs instead of driving them directly from complex logic to avoid excessive ground or supply noise. A transistor or separate gate allows routing the LED current directly to a low impedance point.
A PNP emitter follower should do the trick then... or NPN if I invert the signal on the RX and TX lines in firmware (just some register settings).
I like the idea of pulse stretching via an IOC function but I would use my fast housekeeping interrupt instead of a dedicated timer. Then if I wanted an accurate delay, I would let the fast housekeeping interrupt toggle the LEDs and signal it from the IOC function through a flag to keep interrupt overhead as low as possible. In most applications this level of detail is not required though.
For pulse stretching that would be my approach too, I don't like my interrupt service routines too cluttered.
But if it's just toggling a LED then it's the same as toggling a flag.
Another thing... since this is part of a USB-UART converter (yes, I know, I can get a FT232 or CH340 or MCP2200 to do the same job but I might need the option to reprogram it as a custom HID), what can I do with the 2 extra pins I have left on my micro (PIC16F1459)? Do I really need the RTS/CTS lines or can I get away without them and use a lower pin count micro (PIC16F1454)?