??? 03/10/08 10:17 Read: times |
#152065 - Bit banging UART TX. Responding to: ???'s previous message |
It is easy. The 19200 baud means 52uS per bit.
SoftTX = 1; // start bit delay_us(52); for (i = 8; i--; c >>= 1) { SoftTX = c & 1; // low bit first delay_us(52); } SoftTX = 0; // stop bit delay_us(52); Since you do not seem to need an RX for your printer or LCD, you just steal that pin for the SoftTX. And obviously do not enable RX on your UART. The 8051 drives the LCD TTL directly. If you cannot afford to poll for this length of time, you just set the TX_byte to be handled by a timer IRQ. You could even share the baud rate generator if you used 9600 baud. David. |