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

📄 simple_eos.lst

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

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

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


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