0 Introduction
Most single-chip designs require many pins to implement various input detection and output display or control functions. This is under the premise that the number of pins cannot be increased. It often seems that the number of pins is not enough. Therefore, whether the inherent resources of the chip can be used to the extreme is often the key to determining the cost performance of this system. This article draws on the time-sharing multiplexing principle of the software operating system to divide the task into multiple time slices and execute different tasks in different time slices. In this way, multi-functional control of fewer I/O ports is achieved.
1 Main functions of EM78P156N microcontroller
EM78P156N is an 8-bit microcontroller launched by Taiwan Elan Corporation. Figure 1 shows the pinout of the chip. The main functions of this device are as follows:
◇Working voltage: 2.5~5.5 V;
◇Working temperature range: -40℃~85℃;
◇ The operating frequency range in crystal oscillator mode is: DC~20MHz(5V), DC~8MHz(3V) and DC~4MHz(2.5V); and the frequency range in external RC oscillation is: DC~4MHz(5V), DC~4 MHz(3V) and DC~4MHz(2.5V);
◇Low power consumption: the operating current is less than 2mA when working at 5V/4MHz, 20μA when working at 3V/32kHz, and 1μA when working in sleep mode;
◇With 1K×13B program space;
◇With bidirectional I/O port;
◇There are 5 levels of stack depth;
◇There are 8 programmable pull-up pins, 7 programmable pull-down pins, 8 programmable horizontal drain open-circuit input pins, and 2 programmable R-op-tion pins.
2 Overall design of hardware circuit
The MCU part of the control circuit in this design is shown in Figure 2. The single-chip microcomputer in Figure 2 uses an external RC oscillator with an oscillation frequency of 4MHz. Among them, LED1~LED6 and buttons K2 and K3 share five I/O ports P61~P65. When designing this circuit, it should be noted that pressing the button should not affect the normal lighting of the LED, so a 2kΩ resistor is connected in series between the I/O port and the button, so that even if the button is pressed, the LED can still light up normally. The lighting of each LED lamp must be controlled by two I/O ports at the same time, one is set high and the other is set low, so that the LED can generate a forward voltage drop to light up. The remaining I/O ports are used as normal input and output control.
3. Program Flow
This article takes key input and LED output as an example. Key K2 controls the first group of LEDs 1 to 3 to change as a marquee, and key K3 controls the second group of LEDs 4 to 6 to change as a marquee. Only one of the first and second groups of lights can be lit at the same time. The multiplexing here actually uses the visual persistence function of the human eye. The actual LED is flashing, but the human eye cannot distinguish it. The lighting cycle of each group of lights is 20ms, and the key detection takes about 10μs. In such a short time, it is impossible for the human eye to perceive the change of the LED. Therefore, in actual circuit design, the functions of the human-machine interface such as display and keys are most easily realized in time-sharing multiplexing. The working waveform of the I/O port that lights up LED1 and LED4 is shown in Figure 3. The key detection value is sent to keybuf, and a 20 ms delay comparison test is performed, mainly to increase the reliability of key detection. Its program logic is shown in Figure 4.
It should be noted that when used as a key detection, P6.2, P6.3, and P6.4 must output a high level, or open the internal pull-up as an input port (such as P6.2 in Figure 3). This can prevent the LED from being lit up at this time to form a ghost image, which affects the display effect of the entire system. Of course, the LED driver can also be replaced with a relay with a transistor driver. However, because the relay needs a response process of several milliseconds to close or open, the 10μs time required for key detection is definitely not enough for the relay to change state.
[page]
4. Program Introduction
The following is the display subroutine of this system:
The following are some of the key scanning subroutines in the system:
5 Conclusion
By using the method introduced in this article, a large number of I/O pins can be saved after multiplexing. However, the isolation of input and output must be considered during design, and they cannot affect each other. Even if the output object allows instantaneous jumps that are imperceptible to the human eye, the output control effect cannot be affected.
Previous article:Heterogeneous single-chip computers share external memory and their communication method with microcomputer
Next article:Implementation of Wireless Remote IAP Based on μPSD32xx Series MCU
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- How can a 37-year-old programmer still "dominate the workplace"?
- 【AT-START-F403A Review】+OLED screen driver and application
- How much do you know about the difference between three-phase three-wire and three-phase four-wire meters?
- Inverting adder schematic and circuit diagram
- Application of LM567 Universal Tone Decoder Integrated Circuit
- EEWORLD University - TI gate drivers for every FET
- Please help analyze the role of this voltage regulator diode in the circuit!
- MEMS pressure sensors solve new pain points in human-machine interface
- 2021 Electronic Competition Topic--Nanjing University of Information Science and Technology On-campus Selection Competition Topic
- [Learning Resources] Current Sense Amplifiers from Beginner to Advanced