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

📄 simple_eos.lst

📁 Embedded C 这本书的范例光碟程式
💻 LST
字号:
C51 COMPILER V6.21  SIMPLE_EOS                                                             01/23/2002 17:53:07 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,SPEED) 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 uses T0 (easily adapted for T1) ***
  10          
  11             Demonstration version with dummy task X(). 
  12          
  13          
  14             COPYRIGHT
  15             ---------
  16          
  17             This code is associated with the book:
  18          
  19             EMBEDDED C by Michael J. Pont 
  20             [Pearson Education, 2002: ISBN: 0-201-79523-X].
  21          
  22             This code is copyright (c) 2001 by Michael J. Pont.
  23           
  24             See book for copyright details and other information.
  25          
  26          -*------------------------------------------------------------------*/
  27          
  28          #include "Main.H"
  29          #include "Simple_EOS.H"
  30          
  31          // Header for dummy task 
  32          #include "X.H"
  33          
  34          // ------ Private variable definitions -----------------------------
  35          static tByte Reload_08H;
  36          static tByte Reload_08L;
  37          
  38          // ------ Private function prototypes ------------------------------
  39          static void sEOS_Manual_Timer0_Reload(void);
  40          
  41          
  42          /*------------------------------------------------------------------*-
  43            
  44            sEOS_ISR()
  45          
  46            Invoked periodically by Timer 0 overflow: 
  47            see sEOS_Init_Timer0() for timing details.
  48          
  49          -*------------------------------------------------------------------*/
  50          void sEOS_ISR() interrupt INTERRUPT_Timer_0_Overflow
  51             {
  52   1         // Flag cleared automatically but must reload the timer
  53   1         sEOS_Manual_Timer0_Reload();
  54   1         //===== USER CODE - Begin =======================================
  55   1      
C51 COMPILER V6.21  SIMPLE_EOS                                                             01/23/2002 17:53:07 PAGE 2   

  56   1         // Call dummy task here
  57   1         X();
  58   1      
  59   1         //===== USER CODE - End =========================================
  60   1         }
  61          
  62          /*------------------------------------------------------------------*-
  63            
  64            sEOS_Init_Timer0()
  65          
  66            Sets up Timer 0 to drive the simple EOS.
  67          
  68            Parameter gives tick interval in MILLISECONDS.
  69          
  70            Max tick interval is ~60ms (12 MHz oscillator).
  71          
  72            Note: Precise tick intervals are only possible with certain 
  73            oscillator / tick interval combinations.  If timing is important,
  74            you should check the timing calculations manually. 
  75          
  76          -*------------------------------------------------------------------*/
  77          void sEOS_Init_Timer0(const tByte TICK_MS)
  78             {
  79   1         tLong Inc;
  80   1         tWord Reload_16;
  81   1      
  82   1         // Using Timer 0, 16-bit *** manual reload ***
  83   1         TMOD &= 0xF0; // Clear all T0 bits (T1 left unchanged)
  84   1         TMOD |= 0x01; // Set required T0 bits (T1 left unchanged) 
  85   1      
  86   1         // Number of timer increments required (max 65536)
  87   1         Inc = ((tLong)TICK_MS * (OSC_FREQ/1000)) / (tLong)OSC_PER_INST;   
  88   1      
  89   1         // 16-bit reload value
  90   1         Reload_16 = (tWord) (65536UL - Inc);
  91   1      
  92   1         // 8-bit reload values (High & Low)
  93   1         Reload_08H = (tByte)(Reload_16 / 256);
  94   1         Reload_08L = (tByte)(Reload_16 % 256);
  95   1      
  96   1         // Used for manually checking timing (in simulator)
  97   1         //P2 = Reload_08H;
  98   1         //P3 = Reload_08L;
  99   1      
 100   1         TL0  = Reload_08L; 
 101   1         TH0  = Reload_08H;
 102   1      
 103   1         // Timer 0 interrupt is enabled, and ISR will be called 
 104   1         // whenever the timer overflows.
 105   1         ET0 = 1;
 106   1      
 107   1         // Start Timer 0 running
 108   1         TR0 = 1;     
 109   1      
 110   1         // Globally enable interrupts
 111   1         EA = 1;            
 112   1         }
 113          
 114          /*------------------------------------------------------------------*-
 115            
 116            sEOS_Manual_Timer0_Reload()
 117          
C51 COMPILER V6.21  SIMPLE_EOS                                                             01/23/2002 17:53:07 PAGE 3   

 118            This OS uses a (manually reloaded) 16-bit timer.
 119            The manual reload means that all timings are approximate. 
 120          
 121            THIS OS IS NOT SUITABLE FOR APPLICATIONS WHERE
 122            ACCURATE TIMING IS REQUIRED!!!
 123          
 124            Timer reload is carried out in this function. 
 125          
 126          -*------------------------------------------------------------------*/
 127          void sEOS_Manual_Timer0_Reload()
 128             {
 129   1         // Stop Timer 0
 130   1         TR0 = 0;
 131   1      
 132   1         // See 'init' function for calculations
 133   1         TL0  = Reload_08L; 
 134   1         TH0  = Reload_08H;
 135   1      
 136   1         //  Start Timer 0
 137   1         TR0  = 1;
 138   1         }
 139          
 140          /*------------------------------------------------------------------*-
 141            
 142            sEOS_Go_To_Sleep()
 143          
 144            This operating system enters 'idle mode' between clock ticks
 145            to save power.  The next clock tick will return the processor
 146            to the normal operating state.
 147          
 148            *** ADAPT AS REQUIRED FOR YOUR HARDWARE ***
 149          
 150          -*------------------------------------------------------------------*/
 151          void sEOS_Go_To_Sleep(void)
 152             {
 153   1         PCON |= 0x01;    // Enter idle mode (generic 8051 version)
 154   1         }
 155          
 156          /*------------------------------------------------------------------*-
 157            ---- END OF FILE -------------------------------------------------
 158          -*------------------------------------------------------------------*/


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    136    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      2       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 + -