51 MCU header file

Publisher:sigma28Latest update time:2024-04-10 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.


Reference address:51 MCU header file

Previous article:MCU memory
Next article:51 MCU small project circuit TwoLed circuit diagram

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号