⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mcu.lst

📁 hx8347 初始化,刷屏,图片显示
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.10   MCU                                                                   04/14/2009 23:28:39 PAGE 1   


C51 COMPILER V7.10, COMPILATION OF MODULE MCU
OBJECT MODULE PLACED IN .\mcu.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE ..\SourceFile\mcu.c BROWSE DEBUG OBJECTEXTEND PRINT(.\mcu.lst) OBJECT(.\mcu
                    -.obj)

line level    source

   1          
   2          /***************************************************************************************
   3          ****************************************************************************************
   4          * FILE          : mcu.c
   5          * Description   : 
   6          *                         
   7          * Copyright (c) 2007 by WANG SHAOWEI. All Rights Reserved.
   8          * 
   9          * History:
  10          * Version               Name                    Date                    Description
  11             0.1          WANG SHAOWEI    2007/04/29      Initial Version
  12             
  13          ****************************************************************************************
  14          ****************************************************************************************/
  15          
  16          
  17          
  18          #include "common.h"
  19          
  20          
  21          
  22          /*==================================================================
  23          * Function      : port_init
  24          * Description   : Port init
  25          * Input Para    : void
  26          * Output Para   : void
  27          * Return Value: void
  28          ==================================================================*/
  29          void port_init(void)
  30          {
  31   1              P0 = 0xFF;
  32   1              P1 = 0xFF;
  33   1              P2 = 0xFF;
  34   1              P3 = 0xFF;
  35   1      }
  36          
  37          
  38          
  39          /*==================================================================
  40          * Function      : Interrupt_priority_init
  41          * Description   : 
  42          * Input Para    : 
  43          * Output Para   : 
  44          * Return Value: 
  45          ==================================================================*/
  46          void Interrupt_priority_init(void)
  47          {
  48   1      //UART
  49   1              PS = 1;
  50   1              SETBIT(IPH, 4);         
  51   1      
  52   1      //TIMER2
  53   1              PT2 = 0;
  54   1              SETBIT(IPH, 5);         
C51 COMPILER V7.10   MCU                                                                   04/14/2009 23:28:39 PAGE 2   

  55   1              
  56   1      //TIMER1
  57   1              PT1 = 0;
  58   1              RESETBIT(IPH, 3);       
  59   1      
  60   1      //INT1
  61   1              PX1 = 0;
  62   1              RESETBIT(IPH, 2);       
  63   1      
  64   1      //TIMER0
  65   1              PT0 = 0;
  66   1              RESETBIT(IPH, 1);       
  67   1              
  68   1      //INT0
  69   1              PX0 = 0;
  70   1              RESETBIT(IPH, 0);       
  71   1      }
  72          
  73          
  74          /*==================================================================
  75          * Function      : extern_interrupt0_init
  76          * Description   : 
  77          * Input Para    : 
  78          * Output Para   : 
  79          * Return Value: 
  80          ==================================================================*/
  81          void extern_interrupt0_init(U1 Enable, U1 EdgeEnable)
  82          {
  83   1              IE0 = 0;                                                /*中断标记位*/
  84   1              IT0 = EdgeEnable;
  85   1              EX0 = Enable;
  86   1      }
  87          
  88          
  89          /*==================================================================
  90          * Function      : extern_interrupt1_init
  91          * Description   : 
  92          * Input Para    : 
  93          * Output Para   : 
  94          * Return Value: 
  95          ==================================================================*/
  96          void extern_interrupt1_init(U1 Enable, U1 EdgeEnable)
  97          {
  98   1              IE1 = 0;                                                /*中断标记位*/
  99   1              IT1 = EdgeEnable;
 100   1              EX1 = Enable;
 101   1      }
 102          
 103          
 104          
 105          /*==================================================================
 106          * Function      : mode_init
 107          * Description   : 
 108          * Input Para    : 
 109          * Output Para   : 
 110          * Return Value: 
 111          ==================================================================*/
 112          void mode_init(void)
 113          {
 114   1      #ifdef SPEEDUP
 115   1              SETBIT(CKCON, 0);                                               
 116   1      #else
C51 COMPILER V7.10   MCU                                                                   04/14/2009 23:28:39 PAGE 3   

                      RESETBIT(CKCON, 0);
              #endif
 119   1      }
 120          
 121          /*==================================================================
 122          * Function      : timer0_init
 123          * Description   : Timer0 initialize
 124          * Input Para    : bStart                                Enable Timer0
 125                                    bInt0Relation         Relation with Int0
 126                                    bTimerMode                    0:counter mode, 1:timer mode
 127                                    bInterruptEnable              Interrupt enable
 128                                    WorkMode                      work mode setting,It has 0,1,2,3 four work mode,
 129                                                                          the counter value difference
 130                                                                          0: 13bit counter
 131                                                                          1: 16bit counter
 132                                                                          2: auto load 8bit counter
 133                                                                          3: two 8bit counter
 134                                    TH0Data                       High counter value
 135                                    TL0Data                               Low counter value
 136          * Output Para   : void
 137          * Return Value: void
 138          ==================================================================*/
 139          void timer0_init(U1 Enable,
 140                                          U8 WorkMode,
 141                                          U8 TH0Data,
 142                                          U8 TL0Data)
 143          {       
 144   1              TF0 = 0;                                        /*定时器中断标志位*/
 145   1      
 146   1              RESETBIT(TMOD, 3);              /*不受INT0控制*/
 147   1      
 148   1              RESETBIT(TMOD, 2);              /*定时器计数器模式,TRUE为定时器,FALSE为计数器*/
 149   1      
 150   1              
 151   1      
 152   1              
 153   1              if(WorkMode & 0x02)             /*定时/计数器0工作方式设定*/
 154   1              {
 155   2                      SETBIT(TMOD, 1);                
 156   2              }
 157   1              else
 158   1              {
 159   2                      RESETBIT(TMOD, 1);
 160   2              }
 161   1              
 162   1              if(WorkMode & 0x01)
 163   1              {
 164   2                      SETBIT(TMOD, 0);
 165   2              }
 166   1              else
 167   1              {
 168   2                      RESETBIT(TMOD, 0);
 169   2              }
 170   1              TH0 = TH0Data;
 171   1              TL0 = TL0Data;
 172   1      
 173   1              ET0 = (U1)1;                            /*中断允许*/
 174   1              TR0 = Enable;
 175   1      
 176   1      }
 177          
 178          
C51 COMPILER V7.10   MCU                                                                   04/14/2009 23:28:39 PAGE 4   

 179          /*==================================================================
 180          * Function      : timer2_init
 181          * Description   : The timer2 as system timer,so it only initialize  for system time
 182          * Input Para    : bStart                                Enable Timer2
 183                                    TH2Data                       High counter value
 184          * Output Para   : void
 185          * Return Value: void
 186          ==================================================================*/
 187          void timer2_init(U1 Enable, TimerInterval eTimerInterval)
 188          {
 189   1              TH2 = eTimerInterval;
 190   1              RCAP2H = eTimerInterval;
 191   1      
 192   1              
 193   1              TL2 = 0x00;
 194   1              RCAP2L = 0x00;
 195   1              
 196   1              T2MOD = 0x00;
 197   1              if(Enable)
 198   1              {
 199   2                      T2CON = 0x04;
 200   2              }
 201   1              else
 202   1              {
 203   2                      T2CON = 0x00;
 204   2              }
 205   1      
 206   1              ET2 = 1;
 207   1      }
 208          
 209          
 210          /*==================================================================
 211          * Function      : uart_init
 212          * Description   : UART initialize,use timer1
 213          * Input Para    : UartBaudrate eBaudRate        : baud rate
 214          * Output Para   : void
 215          * Return Value: void
 216          ==================================================================*/
 217          void uart_init(UartBaudrate BaudRate)
 218          {
 219   1              ES = 0;                 /*关串行口中断*/        
 220   1      
 221   1      #ifdef SPEEDUP                  /*串口速度加倍*/
 222   1              RESETBIT(PCON, 7);
 223   1      #else
                      SETBIT(PCON, 7);
              #endif
 226   1      
 227   1              if(BaudRate == UART_RATE1152)
 228   1              {
 229   2                      BaudRate = UART_RATE576;
 230   2                      SETBIT(PCON, 7);
 231   2              }
 232   1      
 233   1              TMOD &= 0x0F;
 234   1              TMOD |= 0x20;
 235   1              ET1 = 0;                                /*中断无效*/
 236   1              TH1 = BaudRate;
 237   1              TL1 = BaudRate;
 238   1              TR1 = 1;                                /*定时器开启*/
 239   1              SCON = 0x50;
 240   1      
C51 COMPILER V7.10   MCU                                                                   04/14/2009 23:28:39 PAGE 5   

 241   1              RI = 0;
 242   1              
 243   1              ES = 1;                         /*串行口中断printf需要串口关闭*/
 244   1      }
 245          
 246          
 247          /*==================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -