51 MCU on-chip devices and interrupts (1)

Publisher:Huayu8888Latest update time:2015-10-12 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Parallel Port Essentials
  1. The MCS-51 microcontroller has four 8-bit parallel I/O ports P0, P1, P2, and P3. Among them, P3, P2, and P1 are quasi-bidirectional ports, and P0 is a bidirectional three-state data line port. Each port is composed of a port latch, an output driver, an input buffer, etc. In addition to byte input/output, each port can also be used as an input/output individually, which is very convenient for practical applications.
  2. The "read-modify-write" instructions for parallel I/O ports (such as CPL P0.0, ANL P1, #0FH, etc.) actually read the contents of the corresponding port latch, modify it, and then write it back to the port latch. The reason why it is "read latch" instead of "read pin" is to avoid misreading caused by changes in the pin status due to external circuits of the pin.
  3. Port P0 is a three-state bidirectional I/O port. When external ROM, RAM, etc. are required, it uses time-division multiplexing and is used as the lower 8 bits of the address bus and the 8-bit data bus through the address latch. When external ROM, RAM, etc. are not required, it is used as a general I/O port. When P0 is used as a general output port, an external pull-up resistor must be connected. When used as an input port, the latch must be written to 1 first. The output stage of port P0 has the ability to drive 8 LSTTL loads.

  4. When there is no need to expand the program memory outside the MCU chip, and only 256 bytes of off-chip RAM need to be expanded, the off-chip RAM can be accessed using the "MOVX A, @Ri", "MOVX @Ri, A" type of instructions. At this time, only the lower 8 bits of the address line are used, and the P2 port is not affected by this type of instruction and can still be used as a general I/O port.

  5. The corresponding port line of P3 port is in the second function, and the conditions that should be met are:

       The serial I/O port is in operation (RXD, TXD).

       External interrupts are enabled (INT0, INT1).

       The timer/counter is in external counting state (T0, T1).

       Executes instructions to read/write external RAM (RD, WR).  

 

Characteristics of the four working modes of timer/counter

  1. Mode 0 is a 13-bit counter with a maximum count value of 213=8192. The counting range is smaller than that of mode 1. It is more troublesome to calculate the initial value of the timing and prone to errors. It has no advantages over mode 1 (the original intention of the design was to be compatible with the earlier 48 series microcontrollers).
  2. Mode 1 is a 16-bit counter with a maximum count value of 216=65536. It has a large counting range and is suitable for applications with a large timing range.
  3. Mode 2 is an 8-bit counter with a maximum count value of 28=256. Its disadvantage is that the counting range is small, but its advantage is that the initial timing value can be automatically restored. It is suitable for applications that require repeated timing but the timing range is not large.
  4. Mode 3 is an 8-bit counter, which is only applicable to T0. T1 does not have mode 3. When T0 is in mode 3, it is split into two independent 8-bit counters TH0 and TL0: TL0 uses the original control register of T0 to form an 8-bit timer/counter; TH0 borrows TF1 and TR1 of T1 and can only count the machine cycle pulses in the machine to form another 8-bit timer. When T0 is in mode 3, T1 mode 2 is used as a serial port baud rate generator.

Calculation of timer initial value

The calculation formula for the timing time is:

    T = (M-TC) × T0    (or TC = MT/T0)

          Where T: the timing time of the timer, that is, the timing time required by the design task;

               T0: The period of the counter counting pulse, which is 12 times the period of the main frequency of the microcontroller system;

               M: The counting modulus value of the counter in the corresponding working mode;

               TC: The initial value that the timer needs to preset.

If the initial value TC is set to 0, the timer timing time is the maximum. When the main frequency of the single-chip microcomputer system is 12MHz, the maximum timing time of the timer under various working modes is:

    Working mode 0    :    Tmax=2^13×1us=8.192ms

    Working mode 1    :    Tmax=2^16×1us=65.536ms

    Working mode 2 and 3:    Tmax=2^8×1us=0.256ms

Reference address:51 MCU on-chip devices and interrupts (1)

Previous article:51 MCU on-chip devices and interrupts (2)
Next article:51 instruction system (1)

Recommended ReadingLatest update time:2024-11-16 22:26

51 MCU: Use timer and LCD1602 to make a simple clock
#include "regx52.h" #include "LCD1602.h" void Delay(int time) {     while(time--) //while loop takes 10us     {     } }  void Timer0Init(void) //1 millisecond @ 11.0592MHz {     TMOD &= 0xF0; //Set timer mode     TMOD |= 0x01; //Set timer mode     TL0 = 0x66; //Set the initial timing value     TH0 = 0xFC; //Set
[Microcontroller]
51 MCU: Use timer and LCD1602 to make a simple clock
LCD display of 51 single chip microcomputer
1. LCD1602 1. Pin display (II) Interpretation of pins Interspersed: 1602: Meaning: can display 2 rows and 16 columns of characters (III) Timing diagram 1, How to see: First make a vertical line time axis t, you can see RS changes first (changes if there is a crossover), then you can see R/W on the same vertical
[Microcontroller]
LCD display of 51 single chip microcomputer
51 MCU Tutorial from Scratch - 27 Matrix Keyboard Interface Technology and Program Design
Matrix keyboard interface technology and program design When there are many buttons in the keyboard of the single-chip computer system, in order to reduce the occupation of the I/O port, the buttons are often arranged in a matrix form, as shown in Figure 1. In a matrix keyboard, each horizontal line and
[Microcontroller]
51 MCU Tutorial from Scratch - 27 Matrix Keyboard Interface Technology and Program Design
The difference between edge triggering and level triggering of 51 single chip microcomputer
Introduction and measurement of edge trigger and level trigger of 51 single-chip microcomputer There are two trigger modes for external interrupt of 51 single-chip microcomputer: level trigger and edge trigger. When level trigger is selected, the single-chip microcomputer checks the interrupt source line in each mac
[Microcontroller]
Design of temperature + smoke alarm system based on 51 single chip microcomputer
1. Hardware Solution This design uses 51 single-chip microcomputer as the core controller, and uses gas sensor MQ-2, ADC0832 analog-to-digital converter, DS18B20 temperature sensor, etc. to realize basic functions. Through these sensors and chips, when the concentration or temperature of combustible gas in the environ
[Microcontroller]
Design of temperature + smoke alarm system based on 51 single chip microcomputer
Summary of 5 common problems in 51 microcontroller applications
This article summarizes some common problems in the application of 51 microcontrollers. These are all things I have actually encountered. Due to the limited length of the article, these problems are far from enough to express the common problems of microcontrollers. I hope it will be helpful to beginners. Please give
[Microcontroller]
Summary of 5 common problems in 51 microcontroller applications
stc89C51 MCU displays some parameters of mpu6050 with 1602
The microcontroller source program is as follows: #include REG52.H          #include math.h //Keil library   #include stdio.h //Keil library         #include INTRINS.H #include "lcd1602.h" typedef unsigned short ushort; typedef unsigned int uint; //**************************************** #define DataPort P0 //
[Microcontroller]
Logic Design of Interface between 51 MCU and FPGA
0 Introduction FPGA is a new type of programmable logic device that can replace all existing microcomputer interface chips and realize multiple functions such as memory and address decoding in microcomputer systems. It has higher density, faster working speed and greater programming flexibility, and is widely used in
[Microcontroller]
Logic Design of Interface between 51 MCU and FPGA
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号