1. Field of the Invention
The present invention relates to chip processors and more particularly to a solution to a current problem encountered with chip processors such as microcontrollers.
2. Description of the Current Art
In a chip processor such as a microcontroller or microprocessor based system it is common to desire to control an individual bit in an output port from software. In order to control one bit without effecting the other bits it is common practice to perform a read of the port then to mask this data with a logical AND operation or a logical OR operation and then write this data back to the port. For example, assuming an 8 bit port(bits 7 through bits 0)in which the programmer wants to set bit 3 (this is the 4th bit), the software would first read the port, then logically OR the data read with the value 08h (00001000 in binary). This sets the bit. Finally the software would write this changed data back to the port. To clear a bit in the port without effecting the other bits, the software would read the port and logically AND the read data with a mask value and then write it back to the port (F7h (11110111 binary) for the above case). This practice is known as a “read modify write operation”. The same concept applies to ports of any width.
Many modern chip processors such as microcontrollers have integrated I/O ports built onto the same chip. Often these ports are designed so they can be dynamically configured to operate either as an input or an output port on a bit by bit basis. In other words, each bit within a port can be dynamically configured as either an input or an output. It is also common to have efficient instructions (op-codes) for the setting or clearing the bits of ports. These instructions normally are capable of performing “read modify read-modify-write” operation directly in hardware by with a single op-code. This saves program space, and more importantly, program execution time.
In a microcontroller based system it is necessary in some cases to have what is called an open drain output where a pin is driven low from a floating state (MOS refers to Metal Oxide Semiconductor transistors common in most microcontrollers). Sometimes this is referred to as an open collector output, using Bipolar Junction Transistor BJT terminology whether or not the system actually uses a BJT or MOS transistor in its output. Sometimes an open source output is used instead of an open drain. The present invention relates equally to open source outputs where a pin is driven a from a floating state to a high state. In the open drain case, an output the pin is either be driven low (where it sinks current) usually representing a binary 0 or allowed to go into a high impedance state (where it draws no current, allowing others to read it or pull it to a fixed level) usually representing a binary 1. Sometime this high impedance state is referred to as a tri-state (or that the line is tri-stated).
It is common practice in the art, and is recommended by many microcontroller manufactures, to implement open drain (or open source) outputs (tri-stated outputs) by configuring the pin as an input rather than an output and using a pull-up or pull-down resistor similar to any tri-state configuration. This permits the manufacturer to implement tri-state configurations (to drive a tri-state bus) without having to actually supply output drivers with three states.
To achieve a workable circuit, the value in the pin output data register is set low for the open drain case with the output pulled high with a resistor. When the pin is configured as an input, goes to a high impedance state and is pulled high by the resistor. When it is desired to drive the pin to a zero (allow it to sink current), the configuration of the pin is changed to be an output. Since there is a 0 in the output data register, the pin is immediately driven low. So instead of setting the data bit high or low as needed in the case of a normal output configuration, the output is driven between the high impedance state and the zero driven state by toggling the input/output configuration bit (commonly called the data direction or DDR bit). The pin can also be used as a receiver or input simply by leaving it configured as an input and reading it in the normal way (where another location on the tri-state bus can pull the bus low). Open source systems work the same way with the states and polarities reversed.
USPTO Backgrounds
USPTO Backgrounds