In general, the best way to reduce the price of cost-sensitive consumer products is to lower chip count as much as possible, leaving more tasks to be performed in software.
For example, in applications where RS-232 transmission is used (remote data loggers or distributed data acquisition systems that use a microcontroller to report data to a host PC computer through RS-232 interfaces), it’s easy to replace the hardware UART and implement this function in software.
It’s also possible, however,. to replace the IC normally needed to translate TTL voltage levels to RS-232 voltage levels (i.e. replace the MC1488 or MAX232 ICs) by using a very simple software trick, creating a direct link between the microcontroller and the serial port of the host PC computer (Fig. 1).
In accordance with the RS-232 standard, a MARK signal (logic “1”) is a negative voltage between −3 V and 25 V, and a SPACE signal (logic “0”) is a positive voltage in the range from +3 V to +25 V. Therefore, if signals are sent between +5 V and −5 V, they will be detected by standard RS-232 receive circuitry as being valid RS-232 signals.
To get these levels with a microcontroller powered only by 5 V, the voltage applied to the common or reference line must be changed to obtain +5 V or −5 V. That is, to transmit a MARK signal (−5 V), the TxD line must be pulled down to 0 V while the GND line is pulled up to +5 V. In this way, the PC will sense a negative voltage between its RxD and GND pins. Similarly, to transmit a SPACE signal (+5 V), the TxD line up must be pulled up to +5 V and the GND line of the microcontroller pulled down to 0 V so that the receiver (PC serial port) can sample a positive voltage between its RxD and GND pins (Fig. 2).
To test this software trick, an assembly language program listing based on the low-cost, low-end Motorola MC68HC705K1 microcontroller is provided (see the listing). It transmits the sentence: “ELECTRONIC DESIGN MAGAZINE: IDEAS FOR DESIGN” over and over again. In addition, it can be displayed on the screen of the PC using the Windows Terminal program configured for 9600 bits/s with 8 data bits, l stop bit, and no parity bits.