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

📄 simple_eos.lst

📁 Embedded C 这本书的范例光碟程式
💻 LST
字号:
C51 COMPILER V6.21  SIMPLE_EOS                                                             01/23/2002 18:09:30 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) 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 robot example. 
  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 "Menu_Robot.H"
  29          #include "Stepper.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 MENU_Command_Processor every 5ms
  49   1         MENU_Command_Processor();
  50   1      
  51   1         // Call Stepper_Update every 100 ms
  52   1         // This ISR is called every 5 ms
  53   1         // - only want to update time every second
  54   1         if (++Call_count_G == 20)
  55   1            {
C51 COMPILER V6.21  SIMPLE_EOS                                                             01/23/2002 18:09:30 PAGE 2   

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

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


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 + -