intrins.h
In C51 MCU programming, the functions in the header file INTRINS.H will make it as easy for you to use as in assembly.
Internal function description
_crol_ Characters rotate left
_cror_ Characters rotate right
_irol_ Integer circular left shift
_iror_ Integer rotate right
_lrol_ Circular left shift of long integer
_lror_ long integer circular right shift
_nop_ No operation 8051 NOP instruction
_testbit_ Test and clear bit 8051 JBC instruction
reg51.h
The operation of P1.1 in the at89x51.h file is written as P1_1
The operation on P1.1 in the reg51.h file is written as P1^1
It's just a different way of expressing it.
1 //Time:2017-2-11
2 //Project Name:reg51.h
3 //write by:cyt
4 /*-------------------------------------------------- ----------
5 REG51.H
6 Header file for generic 80C51 and 80C31 microcontroller.
7 Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc.
8 All rights reserved.
9------------------------------------------------- -----------*/
10 #ifndef __REG51_H__
11 #define __REG51_H__
12 /* BYTE Register */
13 sfr P0 = 0x80;
14 sfr P1 = 0x90;
15 sfr P2 = 0xA0;
16 sfr P3 = 0xB0;
17 sfr PSW = 0xD0;
18 sfr ACC = 0xE0;
19 sfr B = 0xF0;
20 sfr SP = 0x81;
21 sfr DPL = 0x82;
22 sfr DPH = 0x83;
23 sfr PCON = 0x87;
24 sfr TCON = 0x88;
25 sfr TMOD = 0x89;
26 sfr TL0 = 0x8A;
27 sfr TL1 = 0x8B;
28 sfr TH0 = 0x8C;
29 sfr TH1 = 0x8D;
30 sfr IE = 0xA8;
31 sfr IP = 0xB8;
32 sfr SCON = 0x98;
33 sfr SBUF = 0x99;
34 /* BIT Register */
35 /* PSW */
36 sbit CY = 0xD7;
37 sbit AC = 0xD6;
38 sbit F0 = 0xD5;
39 sbit RS1 = 0xD4;
40 sbit RS0 = 0xD3;
41 sbit OV = 0xD2;
42 sbit P = 0xD0;
43 /* TCON */
44sbit TF1 = 0x8F;
45 sbit TR1 = 0x8E;
46 sbit TF0 = 0x8D;
47 sbit TR0 = 0x8C;
48 sbit IE1 = 0x8B;
49 sbit IT1 = 0x8A;
50 sbit IE0 = 0x89;
51 sbit IT0 = 0x88;
52 /* IE */
53 sbit EA = 0xAF;
54 sbit ES = 0xAC;
55 sbit ET1 = 0xAB;
56 sbit EX1 = 0xAA;
57 sbit ET0 = 0xA9;
58 sbit EX0 = 0xA8;
59 /* IP */
60 sbit PS = 0xBC;
61 sbit PT1 = 0xBB;
62 sbit PX1 = 0xBA;
63 sbit PT0 = 0xB9;
64 sbit PX0 = 0xB8;
65 /* P3 */
66 sbit RD = 0xB7;
67 sbit WR = 0xB6;
68 sbit T1 = 0xB5;
69 sbit T0 = 0xB4;
70 sbit INT1 = 0xB3;
71 sbit INT0 = 0xB2;
72sbit TXD = 0xB1;
73 sbit RXD = 0xB0;
74 /* SCON */
75 sbit SM0 = 0x9F;
76 sbit SM1 = 0x9E;
77 sbit SM2 = 0x9D;
78 sbit REN = 0x9C;
79 sbit TB8 = 0x9B;
80 sbit RB8 = 0x9A;
81 sbit TI = 0x99;
82 sbit RI = 0x98;
83 #endif
Definition, sbit has three uses:
The first method: sbit bit variable name = address value
The second method: sbit bit variable name = SFR name ^ variable bit address value
The third method: sbit bit variable name = SFR address value ^ variable bit address value
For example, to define OV in PSW, you can use the following three methods:
sbit OV = 0xd2 (1) Description: 0xd2 is the bit address value of OV
sbit OV = PSW^2 (2) Description: PSW must be defined with sfr first
sbit OV = 0xD0^2 (3) Description: 0xD0 is the address value of PSW
Therefore, here we use sfr P1_0 = P1^0; which means that the symbol P1_0 is used to represent the P1.0 pin. If you want, you can also use a name like P10, as long as you change it in the following program.
Previous article:MCU memory
Next article:51 MCU small project circuit TwoLed circuit diagram
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- MicroPython controlling Arduino via 1-wire
- [Domestic RISC-V Linux Board Fang·Starlight VisionFive Trial Report] Environment Preparation + Server Construction
- External interrupt issues
- 【McQueen Trial】+Motor Control+RGB Color Breathing Light
- How to choose the audio amplifier/boost/charging management IC for Bluetooth speakers?
- Working principle of sampling resistor
- Practical information! The most comprehensive Linux application development case sharing, including key codes!
- EEWORLD University ---- Introduction to Machine Learning
- Which expert can give me some scientific knowledge?
- RF PoL: A Special Variety of Point-of-Load Converters