I/O port multiplexing techniques for EM78P156 microcontroller

Publisher:书卷气息Latest update time:2013-10-16 Source: dzscKeywords:MCU  EM78P156 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Keywords:MCU  EM78P156 Reference address:I/O port multiplexing techniques for EM78P156 microcontroller

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

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号