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-15 07:54

The fourth talk on peripheral modules of microcontroller, basic concepts of USB bus
USB overview USB devices are now a very commonly used interface, and its plug-and-play feature brings great convenience to people. In embedded applications, USB is often used as an interface to communicate with the host computer, and is also used to store data through U disks. USB can be divided into low-speed, ful
[Microcontroller]
Analysis of MCU reset circuit
    At present, single-chip microcomputers have been widely used in home appliances, medical treatment, instrumentation, industrial automation, aerospace and other fields. The more popular types of single-chip microcomputers on the market mainly include 8051 series single-chip microcomputers from Intel, Atmel and Phil
[Microcontroller]
Analysis of MCU reset circuit
Principle design of 7-key and 8-key electronic piano proteus simulation digital tube display program based on 51 single chip microcomputer
hardware design 8-key simulation diagram: plan: 7-key simulation diagram: 7 buttons represent 7 notes, and another button plays a song programming /******************************************************************/ #include reg52.h   #include "main.h" /***********************************************************
[Microcontroller]
Principle design of 7-key and 8-key electronic piano proteus simulation digital tube display program based on 51 single chip microcomputer
Lesson 9: MCU data transfer instructions
MCU data transfer instructions (3) Instructions with direct addresses as destination operands MOV direct,A 例: MOV 20H,A MOV direct,Rn MOV 20H,R1 MOV direct1,direct2 MOV 20H,30H MOV direct,@Ri MOV 20H,@R1 MOV direct,#data MOV 20H,#34H (4) Instructions with indirect addresses as destination operands MOV @Ri,A Exam
[Microcontroller]
51 MCU-Code Comparison
1. Delay function exits the stage With the theoretical explanation in the previous lecture, the implementation of the code is relatively simple. The experimental phenomenon is that the 6 lights in the upper 6 positions keep flowing. We use the K4 button to control the on and off of LED2, and it does not affect the op
[Microcontroller]
Single chip human infrared induction automatic door circuit
The automatic door program design based on 51 single chip microcomputer and human infrared sensing module is shared with everyone The automatic door schematic and PCB diagram drawn by Altium Designer are as follows: (Project files can be downloaded in the 51hei attachment) The microcontroller source program is as fo
[Microcontroller]
Single chip human infrared induction automatic door circuit
MCU clock and different bytes different instruction timing (ALE)
First, paste the structure and circuit of the clock:   Understand what is a machine cycle and an instruction cycle:   The timing of various different bytes and different cycle instructions (important):        
[Microcontroller]
MCU clock and different bytes different instruction timing (ALE)
The basic structure of 80C51 microcontroller
1) Central Processing Unit (CPU) The central processing unit is the core of the microcontroller, completing the calculation and control functions. The CPU of MCS-51 can process 8-bit binary numbers or codes. 2) Internal data memory (internal RAM) There are 256 RAM units in the 8051 chip, but the last 128 unit
[Microcontroller]
The basic structure of 80C51 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号