A kind of button detection and display driving integrated circuit and control method thereof
Technical field
The present invention relates to a kind of button and detect and display driving integrated circuit, the button that is applicable to various electric equipments detects and display driver.The present invention also comprises the control method of this integrated circuit.
Background technology
Existing control system can only be supported less button and LED luminotron usually when general input/output port line (being called for short GPIO) is less, the GPIO utilization factor is lower.The microcontroller that for example is connected to 3 GPIO can only detect 2-3 button usually, drives 2-3 LED luminotron, and as shown in Figure 1,3 GPIO are independent separately, and 1 GPIO connects 1 key press detecting circuit and 1 display driver circuit.When Circuits System is comparatively complicated, when needing the more button of expansion and luminotron, then need the more GPIO of respective extension, cost is higher.
Summary of the invention
The object of the invention is to consider the problems referred to above and provide the relatively less button of a kind of GPIO to detect and display driving integrated circuit that another object of the present invention is to provide the control method of this integrated circuit.
To achieve these goals, the present invention includes following technical characterictic: a kind of button detects and display driving integrated circuit, comprise microcontroller, key press detecting circuit, display driver circuit and universal input and output port GPIO, key press detecting circuit is connected MCU with display driver circuit by GPIO, it is characterized in that the multiplexing one or more GPIO of described key press detecting circuit and display driver circuit, connect the GPIO of key press detecting circuit simultaneously as the AD conversion port.
Further, described key press detecting circuit comprises some button detection modules and two above resistance, and an end was connected with power supply after resistance was in series, and the other end connects microcontroller by GPIO; Per two adjacent resistor contacts connect button detection module one end, button detection module other end ground connection.
Described button detection module comprises button and the stake resistance of series connection.
Further, described display driver circuit comprises display driver unit Q1, the Q2 of some display units and the complementation of two control polarity, the anodal display unit that links to each other with GPIO, and its negative pole links to each other with the Q1 collector, the display unit that negative pole links to each other with GPIO, its positive pole links to each other with the Q2 collector; Per two opposite polarity display units of connection connect same GPIO, and the control port of Q1, Q2 is connected same GPIO with key press detecting circuit.
Described Q1 is NPN type triode; Described Q2 is the positive-negative-positive triode.
Or described display driver unit is switching device.
Described display unit is the luminotron device.
The present invention comprises that also a kind of button detects and the control method of display driving integrated circuit, realizes by the following method control:
A. the microcontroller GPIO port that connects key press detecting circuit is set to input state, the GPIO port voltage is converted to the AD value, thereby judges current key-press status, and button is judged and entered step b after finishing.
B. the microcontroller GPIO port that connects key press detecting circuit is set to output state, and high and low level is exported in timesharing, as the control signal of display driver unit; Display port is exported corresponding high and low level according to the actual displayed content, thus the control display location mode.
The invention solves a kind of identification problem and display driver problem that in the less situation of GPIO, increases the button amount detection, do not need to expand any other device, can under the prerequisite that does not affect properties of product, improve the service efficiency of GPIO, effectively reduce cost of products.Button favorable expandability of the present invention can detect infinite many buttons in theory.Because on system control logic, it is the mode that adopts time-sharing multiplex that button detects with display driver, display tube brightness stability, button good reliability, being specially adapted to all kinds of low costs, human-computer interaction interface simply needs in the electric equipment of button detection and display circuit.
Description of drawings
Fig. 1 is the block diagram of existing button detection and display driver circuit.
Fig. 2 is the circuit block diagram of button detection of the present invention and display driver.
Fig. 3 is the circuit theory diagrams of the embodiment of the invention.
Fig. 4 detects and the display driver circuit schematic diagram for existing button.
Omitted the miscellaneous part related with coreless of the present invention among the figure.
Embodiment
Below in conjunction with accompanying drawing the specific embodiment of the present invention is described further.
Such as Fig. 2, shown in Figure 3, a kind of button detects and display driving integrated circuit, comprises microcontroller, key press detecting circuit 1, display driver circuit 2 and 3 universal input and output port GPIO.
Key press detecting circuit 1 comprises 9 resistance and 4 buttons, wherein, the first resistance R 1, the second resistance R 2, the 3rd resistance R 3, the 4th resistance R 4,5 series connection of the 5th resistance R, the first resistance R 1 other end detects GPIO with button and is connected, and the 5th resistance R 5 other ends are connected with power supply VCC.The first button KEY1 one end connects the connection contact of the first resistance R 1, the second resistance R 2, and the other end is by the 6th resistance R 6 ground connection; The second button KEY2 one end connects the connection contact of the second resistance R 2, the 3rd resistance R 3, and the other end is by the 7th resistance R 7 ground connection; The 3rd button KEY3 one end connects the connection contact of the 3rd resistance R 3, the 4th resistance R 4, and the other end is by the 8th resistance R 8 ground connection; The 4th button KEY4 one end connects the connection contact of the 4th resistance R 4, the 5th resistance R 5, and the other end is by the 9th resistance R 9 ground connection.
Display driver circuit 2 comprises the first triode Q1, the second triode Q2 of LED LED 1, LED2, LED3, LED4 and the complementation of control polarity, wherein LED1, LED2 positive pole are connected with GPIO2, GPIO3 respectively, and negative pole is connected with the first triode Q1 collector; LED3, LED4 negative pole are connected with GPIO2, GPIO3 respectively, and positive pole is connected with the second triode Q2 collector, and the control port of the first triode Q1, the second triode Q2 is connected with the GPIO1 that is connected key press detecting circuit.
Button detects and the control method of display driver circuit is: at first the GPIO1 of system is set to input state, converts the GPIO1 port voltage to the AD value, and by processing such as time-delay, debounces, detects current key-press status; Then, system GPIO1 is set to output state, the output high level, and GPIO2, GPIO3 export respectively high or low level according to actual conditions, are used for lighting or not lighting LED1, LED2; At last, system keeps the GPIO1 output state constant, and output low level, and GPIO2, GPIO3 export respectively low or high level according to actual conditions, are used for lighting or not lighting LED3, LED4; Like this through 3 time-sharing multiplexs, finished once to the detection of all buttons with to the driving of all LED light emitting diodes.
As shown in Figure 4, existing button detects and the display driver circuit technology, such as need 4 buttons and 4 LED light emitting diodes is set, then need 5 GPIO, then only need 3 in the present embodiment, and can expand simultaneously in theory the infinite button that detects more, greatly improved the utilization factor of GPIO.