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

📄 simple_eos.lst

📁 Embedded C 这本书的范例光碟程式
💻 LST
字号:
C51 COMPILER V6.21  SIMPLE_EOS                                                             01/23/2002 17:47:35 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             Demonstration version with dummy task X(). 
  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          // Header for dummy task 
  29          #include "X.H"
  30          
  31          /*------------------------------------------------------------------*-
  32            
  33            sEOS_ISR()
  34          
  35            Invoked periodically by Timer 2 overflow: 
  36            see sEOS_Init_Timer2() for timing details.
  37          
  38          -*------------------------------------------------------------------*/
  39          void sEOS_ISR() interrupt INTERRUPT_Timer_2_Overflow
  40             {
  41   1         // Must manually reset the T2 flag 
  42   1         TF2 = 0;    
  43   1      
  44   1         //===== USER CODE - Begin =======================================
  45   1      
  46   1         // Call dummy task here
  47   1         X();
  48   1      
  49   1         //===== USER CODE - End =========================================
  50   1         }
  51          
  52          /*------------------------------------------------------------------*-
  53            
  54            sEOS_Init_Timer2()
  55          
C51 COMPILER V6.21  SIMPLE_EOS                                                             01/23/2002 17:47:35 PAGE 2   

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

 118             {
 119   1         PCON |= 0x01;    // Enter idle mode (generic 8051 version)
 120   1         }
 121          
 122          /*------------------------------------------------------------------*-
 123            ---- END OF FILE -------------------------------------------------
 124          -*------------------------------------------------------------------*/


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