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

📄 main.lst

📁 C8051F226单片机的初始化
💻 LST
字号:
C51 COMPILER V7.50   MAIN                                                                  09/18/2008 15:29:03 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: D:\Keil C51\C51\BIN\C51.EXE main.c OPTIMIZE(9,SPEED) BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include <c8051F340.h>
   2          //#include <stdio.h>
   3          //#include <absacc.h>
   4          //#include <math.h>
   5          #include <intrins.h>
   6          #include "ZLG7290.h"
   7          #include "I2C.h"        
   8          
   9          #define uchar unsigned char 
  10          #define uint unsigned int
  11          
  12          //sbit LedLink = P4^7;   //P4口不可位寻址
  13          #define LedLink  1 << 7
  14          
  15          volatile bit FlagINT = 0;
  16          
  17          
  18          unsigned char Read_Buffer[10];
  19          unsigned char Write_Buffer[10] ={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0xFF};
  20          /*---------------------------------------------
  21          函数名:INT1_Init
  22          功  能:外部中断1初始化
  23          参  数:无
  24          返回值:无
  25          修改记录
  26          ----------------------------------------------
  27          日期     作者      内容
  28          
  29          ---------------------------------------------*/
  30          void INT1_Init(void)
  31          {
  32   1       IT01CF |= 0x40;//INT1连接到P0.4  低电平触发中断 
  33   1      
  34   1       IT1 = 0x00;    //低电平触发中断
  35   1       EX1 = 0x01;    //允许外部中断 
  36   1      }
  37          
  38          
  39          //*******************************************************************
  40          //函数:INT0_SVC()
  41          //功能:ZLG7290键盘中断服务程序
  42          //说明:中断触发方式选择负边沿触发,因此不必等待中断请求信号恢复为高电平
  43          //********************************************************************
  44          void INT1_ISR(void) interrupt 2 using 1
  45          {
  46   1       FlagINT = 1;
  47   1      }
  48          
  49          /*---------------------------------------------
  50          函数名:deley_us
  51          功  能:延时us级子程序
  52          参  数:unsigned char Nus
  53          返回值:无
  54          修改记录
  55          ----------------------------------------------
C51 COMPILER V7.50   MAIN                                                                  09/18/2008 15:29:03 PAGE 2   

  56          日期     作者      内容
  57          
  58          ---------------------------------------------*/
  59          void deley_us(unsigned char Nus)
  60          {
  61   1       unsigned char i;
  62   1       for(i=0;i<Nus;i++)
  63   1       {
  64   2        _nop_();
  65   2        _nop_();
  66   2        _nop_();
  67   2        _nop_();
  68   2        _nop_();
  69   2       }
  70   1      }
  71          
  72          /*---------------------------------------------
  73          函数名:deley_ms
  74          功  能:延时ms级子程序
  75          参  数:unsigned char Nms
  76          返回值:无
  77          修改记录
  78          ----------------------------------------------
  79          日期     作者      内容
  80          
  81          ---------------------------------------------*/
  82          void deley_ms(unsigned char Nms)
  83          {
  84   1       unsigned char i;
  85   1       for(i=0;i<Nms;i++)
  86   1       {
  87   2        deley_us(250);
  88   2       }
  89   1      }
  90          
  91          
  92          /*******************************************
  93          //采用外部晶振初始化程序(11.0592MHZ)
  94          *******************************************/
  95          void Oscillator_Init(void)
  96          {
  97   1          unsigned int i;
  98   1      
  99   1          OSCXCN = 0x67;
 100   1          for (i = 0; i < 3000; i++);  // Wait 1ms for initialization
 101   1      
 102   1          while ((OSCXCN & 0x80) == 0);
 103   1      
 104   1          RSTSRC = 0x06;  //Enable missing clock detector and VDD Monitor reset
 105   1          CLKMUL = 0x02;
 106   1          CLKSEL = 0x01;  //系统时钟选择外部振荡器 USB时钟选择外部振荡器
 107   1              OSCICN = 0x00;  //内部高频振荡器禁止
 108   1      }
 109          
 110          /**********************************************
 111          //名称:System_init()
 112          //功能:系统初始化函数
 113          //输入:无
 114          //返回:无
 115          **********************************************/
 116          void System_init(void)
 117          {
C51 COMPILER V7.50   MAIN                                                                  09/18/2008 15:29:03 PAGE 3   

 118   1          EA = 0;                       
 119   1          PCA0MD &= ~0x40; //看门狗关
 120   1          PCA0MD = 0x00;
 121   1              //WDTCN = 0x0de;
 122   1              //WDTCN = 0x0ad;  //disable WDTz
 123   1      
 124   1          P0MDIN = 0x03f;       //P0.6, P0.7 are analog 
 125   1              P1MDIN = 0x0ff;
 126   1              P2MDIN = 0x0ff;
 127   1          P3MDIN = 0x0ff;
 128   1          P4MDIN = 0x0ff;   //数字输入使能
 129   1      
 130   1              P0MDOUT = 0x0ff;  
 131   1              P1MDOUT = 0x0ff;
 132   1              P2MDOUT = 0x0ff;
 133   1          P3MDOUT = 0x0ff;
 134   1          P4MDOUT = 0x0ff;  //IO口为推挽输出
 135   1          
 136   1          P0SKIP = 0xc0;    //P0.6, P0.7 skipped in the Crossbar 
 137   1          P1SKIP = 0x00;
 138   1          P2SKIP = 0x00;
 139   1          P3SKIP = 0x00;
 140   1          //P4SKIP = 0x00;   //引脚不被交叉开关跳过
 141   1      
 142   1          XBR0 = 0x08;       //Route /SYSCLK to first available pin
 143   1          XBR1 = 0x00;
 144   1          XBR2 = 0x00;
 145   1          
 146   1          XBR1 |= 0x40;     //使能交叉开关
 147   1          Oscillator_Init();//外部晶振初始化程序
 148   1          RS0=0;
 149   1          RS1=0;            //设置工作寄存器组为0.
 150   1              
 151   1              IE = 0x80;                //开中断
 152   1      }
 153          
 154          
 155          /*******************************************
 156          //主程序
 157          *******************************************/
 158          void main(void) 
 159          {   
 160   1       unsigned char KeyValue = 0;
 161   1      
 162   1       System_init();
 163   1       deley_ms(250);
 164   1       deley_ms(250);
 165   1       //LedLink = 1;
 166   1       P4 &= ~LedLink;
 167   1      
 168   1       INT1_Init();
 169   1       I2C_Init();
 170   1       //wrnbyt(0x00,10,Write_Buffer);
 171   1       //deley_ms(250);
 172   1       //deley_ms(250);
 173   1       //rdnbyt(0x00,10,Read_Buffer);
 174   1      
 175   1       while(1)
 176   1       {
 177   2        if(FlagINT)           
 178   2        {//如果有键按下,产生中断      
 179   3         FlagINT = 0;  //清除中断标志
C51 COMPILER V7.50   MAIN                                                                  09/18/2008 15:29:03 PAGE 4   

 180   3         KeyValue = ZLG7290_ReadReg(0x01);//读取键值
 181   3        }
 182   2        P4 |= LedLink;
 183   2        deley_ms(250);
 184   2        deley_ms(250);
 185   2        deley_ms(250);
 186   2        deley_ms(250);
 187   2        P4 &= ~LedLink;
 188   2        deley_ms(250);
 189   2        deley_ms(250);
 190   2        deley_ms(250);
 191   2        deley_ms(250);
 192   2        
 193   2       }
 194   1      }


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


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

⌨️ 快捷键说明

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