• 51单片机头文件


    reg51.h

    at89x51.h文件中对P1.1的操作是写成P1_1

    reg51.h文件中对P1.1的操作是写成P1^1

     

    定义,sbit 的用法有三种:

     

    第一种方法:sbit 位变量名=地址值
    第二种方法:sbit 位变量名=SFR 名称^变量位地址值
    第三种方法:sbit 位变量名=SFR 地址值^变量位地址值
    如定义PSW 中的OV 可以用以下三种方法:
    sbit OV=0xd2 (1)说明:0xd2 是OV 的位地址值
    sbit OV=PSW^2 (2)说明:其中PSW 必须先用sfr 定义好
    sbit OV=0xD0^2 (3)说明:0xD0 就是PSW 的地址值
    因此这里用sfr P1_0=P1^0;就是定义用符号P1_0 来表示P1.0 引脚,如果你愿意也可以起P10 一类的名字,只要下面程序中也随之更改就行了。

     

     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 */
    44 sbit 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;
    72 sbit 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

     

  • 相关阅读:
    js炫酷效果
    程序员的执着
    [心得]docker学习笔记
    [心得笔记]多线程之间的内存可见性问题
    Docker入门
    [心得体会]jvm
    redis学习总结
    [心得]redis集群环境搭建的错误
    Linux安装mysql5.7版本
    Cent OS下安装JDK11
  • 原文地址:https://www.cnblogs.com/zhj868/p/14158073.html
Copyright © 2020-2023  润新知