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

📄 simple_eos.lst

📁 < C语言嵌入式系统开发>>一书配套源代码,C51代码,对于51学习有很好参考意义.
💻 LST
字号:
C51 COMPILER V6.21  SIMPLE_EOS                                                             01/23/2002 18:04:15 PAGE 1   


C51 COMPILER V6.21, COMPILATION OF MODULE SIMPLE_EOS
OBJECT MODULE PLACED IN Simple_EOS.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE Simple_EOS.c OPTIMIZE(6,SIZE) BROWSE DEBUG OBJECTEXTEND

stmt level    source

   1          /*------------------------------------------------------------------*-
   2          
   3             Simple_EOS.C (v1.00)
   4          
   5            ------------------------------------------------------------------
   6          
   7             Main file for Simple Embedded Operating System (sEOS) for 8051.
   8          
   9             - This version for project TIME (Chap 9). 
  10          
  11             COPYRIGHT
  12             ---------
  13          
  14             This code is associated with the book:
  15          
  16             EMBEDDED C by Michael J. Pont 
  17             [Pearson Education, 2002: ISBN: 0-201-79523-X].
  18          
  19             This code is copyright (c) 2001 by Michael J. Pont.
  20           
  21             See book for copyright details and other information.
  22          
  23          -*------------------------------------------------------------------*/
  24          
  25          #include "Main.H"
  26          #include "Simple_EOS.H"
  27          
  28          #include "PC_O.H"
  29          #include "Elap_232.H"
  30          
  31          // ------ Private variable definitions -----------------------------
  32          static tByte Call_count_G = 0;
  33          
  34          
  35          /*------------------------------------------------------------------*-
  36            
  37            sEOS_ISR()
  38          
  39            Invoked periodically by Timer 2 overflow: 
  40            see sEOS_Init_Timer2() for timing details.
  41          
  42          -*------------------------------------------------------------------*/
  43          void sEOS_ISR() interrupt INTERRUPT_Timer_2_Overflow
  44             {
  45   1         TF2 = 0;  // Must manually reset the T2 flag   
  46   1      
  47   1         //===== USER CODE - Begin =======================================
  48   1         // Call RS-232 update function every 5ms
  49   1         PC_LINK_O_Update();
  50   1      
  51   1         // This ISR is called every 5 ms
  52   1         // - only want to update time every second
  53   1         if (++Call_count_G == 200)
  54   1            {
  55   2            // Time to update time
C51 COMPILER V6.21  SIMPLE_EOS                                                             01/23/2002 18:04:15 PAGE 2   

  56   2            Call_count_G = 0;
  57   2      
  58   2            // Call time update function
  59   2            Elapsed_Time_RS232_Update();
  60   2            }
  61   1         //===== USER CODE - End =========================================
  62   1         }
  63          
  64          /*------------------------------------------------------------------*-
  65            
  66            sEOS_Init_Timer2()
  67          
  68            Sets up Timer 2 to drive the simple EOS.
  69          
  70            Parameter gives tick interval in MILLISECONDS.
  71          
  72            Max tick interval is ~60ms (12 MHz oscillator).
  73          
  74            Note: Precise tick intervals are only possible with certain 
  75            oscillator / tick interval combinations.  If timing is important,
  76            you should check the timing calculations manually. 
  77          
  78          -*------------------------------------------------------------------*/
  79          void sEOS_Init_Timer2(const tByte TICK_MS)
  80             {
  81   1         tLong Inc;
  82   1         tWord Reload_16;
  83   1         tByte Reload_08H, Reload_08L;
  84   1      
  85   1         // Timer 2 is configured as a 16-bit timer,
  86   1         // which is automatically reloaded when it overflows
  87   1         T2CON   = 0x04;   // Load Timer 2 control register
  88   1      
  89   1         // Number of timer increments required (max 65536)
  90   1         Inc = ((tLong)TICK_MS * (OSC_FREQ/1000)) / (tLong)OSC_PER_INST;   
  91   1      
  92   1         // 16-bit reload value
  93   1         Reload_16 = (tWord) (65536UL - Inc);
  94   1      
  95   1         // 8-bit reload values (High & Low)
  96   1         Reload_08H = (tByte)(Reload_16 / 256);
  97   1         Reload_08L = (tByte)(Reload_16 % 256);
  98   1      
  99   1         // Used for manually checking timing (in simulator)
 100   1         //P2 = Reload_08H;
 101   1         //P3 = Reload_08L;
 102   1      
 103   1         TH2     = Reload_08H;   // Load Timer 2 high byte
 104   1         RCAP2H  = Reload_08H;   // Load Timer 2 reload capt. reg. high byte
 105   1         TL2     = Reload_08L;   // Load Timer 2 low byte
 106   1         RCAP2L  = Reload_08L;   // Load Timer 2 reload capt. reg. low byte
 107   1      
 108   1         // Timer 2 interrupt is enabled, and ISR will be called 
 109   1         // whenever the timer overflows.
 110   1         ET2     = 1;
 111   1      
 112   1         // Start Timer 2 running
 113   1         TR2   = 1;     
 114   1      
 115   1         EA = 1;            // Globally enable interrupts
 116   1         }
 117          
C51 COMPILER V6.21  SIMPLE_EOS                                                             01/23/2002 18:04:15 PAGE 3   

 118          /*------------------------------------------------------------------*-
 119            
 120            sEOS_Go_To_Sleep()
 121          
 122            This operating system enters 'idle mode' between clock ticks
 123            to save power.  The next clock tick will return the processor
 124            to the normal operating state.
 125          
 126            *** ADAPT AS REQUIRED FOR YOUR HARDWARE ***
 127          
 128          -*------------------------------------------------------------------*/
 129          void sEOS_Go_To_Sleep(void)
 130             {
 131   1         PCON |= 0x01;    // Enter idle mode (generic 8051 version)
 132   1         }
 133          
 134          /*------------------------------------------------------------------*-
 135            ---- END OF FILE -------------------------------------------------
 136          -*------------------------------------------------------------------*/


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


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

⌨️ 快捷键说明

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