STC12C5A60S2 MCU IO port working mode setting

Publisher:大树下的大白菜yLatest update time:2015-08-10 Source: 21icKeywords:STC12C5A60S2 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

STC12C5A60S2 MCU IO port working mode setting
  All I/O ports of STC12C5A60S2 series MCU can be configured by software into one of four working types. The four types are: quasi-bidirectional port (standard 8051 output mode), push-pull output, input only (high impedance) or open-drain output function.
Each port is controlled by the corresponding bits in the 2 control registers.
After power-on reset, the STC12C5A60S2 series MCU is in quasi-bidirectional port (traditional 8051 I/O port) mode. It is high level when it is above 2V and low level when it is below 0.8V.

I/O port working type setting
PxM1[7:0] PxM0[7:0] I/O port mode
0 0 Quasi-bidirectional port (traditional 8051 I/O port mode), sink current up to 20mA, source current 230uA
0 1 Push-pull output (strong pull-up output, up to 20mA, current limiting resistor required)
1 0 Input only (high impedance)
1 1 Open drain (Open Drain), internal pull-up resistor disconnected, external pull-up resistor required

Note:
  Although each I/O port can withstand 20mA sink current in weak pull-up (current limiting resistors such as 1K, 560Ω, etc.) and can output 20mA source current in strong push-pull output (current limiting resistors are also required), the recommended operating current of the entire chip should not exceed 55mA. That is, the current flowing in from MCU-VCC should not exceed 55mA, the current flowing out from MCU-GND should not exceed 55mA, and the overall inflow/outflow current should not exceed 55mA.

Here is a macro definition: _BIN
is used to assign a value to each bit of the register. For example:
ADC_CONTR = _BIN(1,0,0,0, 1,0,0,0);
assigns 1 to the 7th and 3rd bits of the ADC_CONTR register, and the other bits are 0. The parameters in brackets are bits 7 to 0.

In the TF card program, if the SPI port is set to push-pull (strong pull-up) output, you can write it like this:
P1M1 = _BIN(0,0,0,0,0,0,0,0);
P1M0 = _BIN(1,1,1,1,1,1,1,1);

Keywords:STC12C5A60S2 Reference address:STC12C5A60S2 MCU IO port working mode setting

Previous article:Liujing MCU Bidirectional Thyristor Interface MDK160
Next article:C language program for I2C communication

Recommended ReadingLatest update time:2024-11-23 08:05

Application of SH79F168 microcontroller in brushless ESC of model aircraft
1 Overview The sensorless brushless DC motor (BLDCM) has been widely used in the field of model aircraft due to its high speed, high reliability, small size and light weight. However, compared with brushed motors and brushless DC motors with position sensors, its control algorithm is much more complicated. In a
[Microcontroller]
Application of SH79F168 microcontroller in brushless ESC of model aircraft
Use of EEPROM inside STC microcontroller - Recording power-on times
In most cases, 24C02 is used to store power-off data. In some situations where cost needs to be considered, the internal EEPROM can also be considered. This program introduces the use of the EEPROM inside the STC. The function of the program is to record the number of power-on times, then add 1 and display it on the d
[Microcontroller]
Course Design Topic 33: Electronic Clock Based on Single Chip Microcomputer
1) Design task: Design an electronic clock that can display the current year, month, day, hour, minute and second and has an alarm function. 2) Index requirements (1) It can realize the conversion between 12-hour system and 24-hour system. (2) Year, month, day, hour and minute can be set individually. The item w
[Microcontroller]
Course Design Topic 33: Electronic Clock Based on Single Chip Microcomputer
Analysis of the servo program using 51 single-chip microcomputer
A servo, also known as a servo motor, is an electromechanical structure with a closed-loop control system. A servo is mainly composed of a housing, a circuit board, a coreless motor, gears, and a position detector. Its working principle is that the controller sends a PWM (pulse width modulation) signal to the servo, w
[Microcontroller]
Schematic diagram of liquid level remote monitor based on STC89C52 microcontroller
This design consists of a master machine and a slave machine. The host is composed of STC89C52 microcontroller circuit + Bluetooth host circuit + ultrasonic ranging module circuit + power supply circuit. The slave machine is composed of STC89C52 microcontroller circuit + LCD1602 liquid crystal display circuit + Blue
[Microcontroller]
Schematic diagram of liquid level remote monitor based on STC89C52 microcontroller
Things that are easy to overlook in 51 single chip microcomputers
Port P0 will be used as the lower 8-bit address line and 8-bit data line of the bus Port P2 will be used as the high 8-bit address line of the bus If the hexadecimal number starts with one of the letters ABCDEF, you must add a 0 in front of it. For example, MOV P1, #0BFH ORG 00H indicates a pseudo instruction, w
[Microcontroller]
LED Intelligent Lighting System Based on STC Microcontroller
1 Introduction LED is called the fourth generation of lighting source or green light source. The light-emitting device of LED is a cold light source, which has the characteristics of energy saving, environmental protection, long life and small size. The light efficiency of incandescent lamps a
[Microcontroller]
LED Intelligent Lighting System Based on STC Microcontroller
Research scheme of photoelectric tracking servo system based on MSP430 microcontroller
  The research design utilizes the principle that photosensors are sensitive to light signals in a specific wavelength range, combines a four-quadrant photoelectric position detector with an MSP430 series single-chip microcomputer, and based on the linear relationship between the output voltage of the four-quadrant ph
[Microcontroller]
Research scheme of photoelectric tracking servo system based on MSP430 microcontroller
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号