C51 COMPILER V9.54   IO                                                                    12/03/2024 14:58:47 PAGE 1   


C51 COMPILER V9.54, COMPILATION OF MODULE IO
OBJECT MODULE PLACED IN .\Objects\io.obj
COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE public\io.c OPTIMIZE(8,SPEED) BROWSE INCDIR(.\public) DEBUG OBJECTEXTEND
                    - PRINT(.\Listings\io.lst) OBJECT(.\Objects\io.obj)

line level    source

   1          #include "io.h"
   2          
   3          //如果使用keil仿真调试，不能操作P0.5，P0.6口，否则会运行出错
   4          //P0/P1/P2/P3 口可按位操作,P4/P5 口只能寄存器操作   P5.5为RST口
   5          /*将所有IO寄存器清零*/
   6          void IO_CLR()
   7          {
   8   1          P0CR = 0xFF;                //PxCR=0是输入，=1是输出
   9   1          P1CR = 0xFF;
  10   1          P2CR = 0xFF;
  11   1          P3CR = 0xFF;
  12   1          P4CR = 0xFF;
  13   1          P5CR = 0x3F;                //0011 1111
  14   1              
  15   1          P0PCR = 0x00;               //PxPCR=0是上拉禁止，=1是上拉使能
  16   1          P1PCR = 0x00;
  17   1          P2PCR = 0x00;
  18   1          P3PCR = 0x00;
  19   1          P4PCR = 0x00;
  20   1          P5PCR = 0x00;
  21   1              
  22   1                      ALFSEL0 = 0x00;         //复用选择寄存器
  23   1                      ALFSEL1 = 0x00;         //复用选择寄存器 
  24   1              
  25   1                      P0 = 0;         //所有引脚输出低电平
  26   1          P1 = 0;
  27   1          P2 = 0;
  28   1          P3 = 0;
  29   1          P4 = 0;
  30   1          P5 = 0;
  31   1                      delay_ms(100);
  32   1      }
  33          
  34          void IO_Test(void)
  35          { 
  36   1              //IO设置输出
  37   1              P0CR |= 0x9F;           //1001 1111             使用|=操作的话可以保留第5,6位原本的状态 这里5,6两位做SWD调试接口了
  38   1              P1CR |= 0xFF;
  39   1              P2CR |= 0xFF;   
  40   1              P3CR |= 0xFF;
  41   1              P4CR = 0xFF;
  42   1              P5CR = 0x1F;            //0001 1111
  43   1              
  44   1              while(1)
  45   1              {
  46   2                      P0 |= 0x9F;
  47   2                      P1 |= 0xFF;
  48   2                      P2 |= 0xFF;
  49   2                      P3 |= 0xFF;
  50   2                      P4 = 0xFF;
  51   2                      P5 = 0x1F;              
  52   2                      delay_ms(100);
  53   2                      P0 &= 0x60;             //0110 0000
  54   2                      P1 &= 0x00;
C51 COMPILER V9.54   IO                                                                    12/03/2024 14:58:47 PAGE 2   

  55   2                      P2 &= 0x00;
  56   2                      P3 &= 0x00;
  57   2                      P4 = 0x00;
  58   2                      P5 = 0x00;
  59   2                      delay_ms(100);
  60   2              }
  61   1      }


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    121    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
