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

📄 simple_eos.lst

📁 单片机C51源程序有电动恐龙
💻 LST
字号:
C51 COMPILER V6.21  SIMPLE_EOS                                                             03/28/2006 17:41:39 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          
  10             COPYRIGHT
  11             ---------
  12          
  13             This code is associated with the book:
  14          
  15             EMBEDDED C by Michael J. Pont 
  16             [Pearson Education, 2002: ISBN: 0-201-79523-X].
  17          
  18             This code is copyright (c) 2001 by Michael J. Pont.
  19           
  20             See book for copyright details and other information.
  21          
  22          -*------------------------------------------------------------------*/
  23          
  24          #include "Main.H"
  25          #include "Simple_EOS.H"
  26          
  27          #include "Dinosaur.H"
  28          
  29          // ------ Private variable definitions -----------------------------
  30          static tByte Call_count_G;
  31          
  32          
  33          /*------------------------------------------------------------------*-
  34            
  35            sEOS_ISR()
  36          
  37            Invoked periodically by Timer 2 overflow: 
  38            see sEOS_Init_Timer2() for timing details.
  39          
  40          -*------------------------------------------------------------------*/
  41          void sEOS_ISR() interrupt INTERRUPT_Timer_2_Overflow
  42             {
  43   1         TF2 = 0;  // Must manually reset the T2 flag   
  44   1      
  45   1         //===== USER CODE - Begin =======================================
  46   1         // This ISR is called every 50 ms
  47   1         // - only want to update dinosaur state every second
  48   1         if (++Call_count_G < 20)
  49   1            {
  50   2            return;
  51   2            }
  52   1      
  53   1         // Time to update state,
  54   1         Call_count_G = 0;
  55   1      
C51 COMPILER V6.21  SIMPLE_EOS                                                             03/28/2006 17:41:39 PAGE 2   

  56   1         // Call traffic lights update function
  57   1         DINOSAUR_Update();
  58   1         //===== USER CODE - End =========================================
  59   1         }
  60          
  61          /*------------------------------------------------------------------*-
  62            
  63            sEOS_Init_Timer2()
  64          
  65            Sets up Timer 2 to drive the simple EOS.
  66          
  67            Parameter gives tick interval in MILLISECONDS.
  68          
  69            Max tick interval is ~60ms (12 MHz oscillator).
  70          
  71            Note: Precise tick intervals are only possible with certain 
  72            oscillator / tick interval combinations.  If timing is important,
  73            you should check the timing calculations manually. 
  74          
  75          -*------------------------------------------------------------------*/
  76          void sEOS_Init_Timer2(const tByte TICK_MS)
  77             {
  78   1         tLong Inc;
  79   1         tWord Reload_16;
  80   1         tByte Reload_08H, Reload_08L;
  81   1      
  82   1         // Timer 2 is configured as a 16-bit timer,
  83   1         // which is automatically reloaded when it overflows
  84   1         T2CON   = 0x04;   // Load Timer 2 control register
  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) (65536 - 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         TH2     = Reload_08H;   // Load Timer 2 high byte
 101   1         RCAP2H  = Reload_08H;   // Load Timer 2 reload capt. reg. high byte
 102   1         TL2     = Reload_08L;   // Load Timer 2 low byte
 103   1         RCAP2L  = Reload_08L;   // Load Timer 2 reload capt. reg. low byte
 104   1      
 105   1         // Timer 2 interrupt is enabled, and ISR will be called 
 106   1         // whenever the timer overflows.
 107   1         ET2     =1 ;
 108   1      
 109   1         // Start Timer 2 running
 110   1         TR2   = 1;     
 111   1      
 112   1         EA = 1;            // Globally enable interrupts
 113   1         }
 114          
 115          /*------------------------------------------------------------------*-
 116            
 117            sEOS_Go_To_Sleep()
C51 COMPILER V6.21  SIMPLE_EOS                                                             03/28/2006 17:41:39 PAGE 3   

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


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    135    ----
   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 + -