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

📄 sch51.lst

📁 移植于51单片机上的ucos。SCH51-OS是整个工程项目
💻 LST
字号:
C51 COMPILER V8.05a   SCH51                                                                11/09/2008 23:18:21 PAGE 1   


C51 COMPILER V8.05a, COMPILATION OF MODULE SCH51
OBJECT MODULE PLACED IN SCH51.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE SCH51.c BROWSE DEBUG OBJECTEXTEND

line level    source

   1          #include  "ExtDef.h"   // the same as REG52.h except for masking two definition about P1, lest for avoidin
             -g multiple definition
   2          #define   SCH_MAX_TASKS    5
   3          
   4          typedef xdata struct     //定义任务结构
   5          {
   6             void (code * pTask)(void);    
   7             uint  Delay;         
   8             uint  Period;        
   9             uchar RunMe;                           
  10          }sTask;
  11          
  12          sTask SCH_tasks_G[SCH_MAX_TASKS];         //定义任务数据结构
  13          
  14          
  15          //-----------------------任务开始---------------------
  16          void SCH_Start(void) 
  17          {
  18   1           EA = 1;
  19   1      }
  20          
  21          //-----------------------系统进入空闲模式,等待下一次刷新---------
  22          void SCH_Go_To_Sleep()
  23          {
  24   1         PCON |= 0x01;   
  25   1         
  26   1      }
  27          //------------------------任务添加---------------------
  28           
  29          uchar SCH_Add_Task(void (code * pFunction)(),const uint DELAY,const uint PERIOD)    
  30          {
  31   1         uchar Index = 0;
  32   1         
  33   1         while ((SCH_tasks_G[Index].pTask != 0) && (Index < SCH_MAX_TASKS))
  34   1         {
  35   2            Index++;                           //查找空的任务指针
  36   2         } 
  37   1         
  38   1           
  39   1         if (Index == SCH_MAX_TASKS)
  40   1          {
  41   2             return 0;  
  42   2          }
  43   1            
  44   1         
  45   1         SCH_tasks_G[Index].pTask  = pFunction;
  46   1         SCH_tasks_G[Index].Delay  = DELAY;            
  47   1         SCH_tasks_G[Index].Period = PERIOD;
  48   1      
  49   1         SCH_tasks_G[Index].RunMe  = 0;
  50   1      
  51   1         return Index; 
  52   1      }
  53          
  54          
C51 COMPILER V8.05a   SCH51                                                                11/09/2008 23:18:21 PAGE 2   

  55          //-----------------------任务删除-----------------------
  56          
  57          bit SCH_Delete_Task(const uchar TASK_INDEX) 
  58          {
  59   1         
  60   1         if (SCH_tasks_G[TASK_INDEX].pTask == 0)
  61   1         {
  62   2              return 0;
  63   2          }
  64   1            
  65   1         SCH_tasks_G[TASK_INDEX].pTask   = 0x0000;
  66   1         SCH_tasks_G[TASK_INDEX].Delay   = 0;
  67   1         SCH_tasks_G[TASK_INDEX].Period  = 0;
  68   1         SCH_tasks_G[TASK_INDEX].RunMe   = 0;
  69   1      
  70   1         return 0;
  71   1      }
  72          
  73          //------------------------------任务调度---------------------
  74          
  75          void SCH_Dispatch_Tasks(void) 
  76          {
  77   1               
  78   1         static uchar Index;  // Index must be defined as static attribute,or it may be changed when executing: (
             -*SCH_tasks_G[Index].pTask)();
  79   1         
  80   1         for (Index = 0; Index < SCH_MAX_TASKS; Index++)
  81   1         {
  82   2            if (SCH_tasks_G[Index].RunMe > 0) 
  83   2             {
  84   3                 (*SCH_tasks_G[Index].pTask)();       // to execute task[index],so task's priority are decided by the
             - tasks' established seqence.
  85   3                              SCH_tasks_G[Index].RunMe -= 1;   
  86   3      
  87   3              
  88   3              
  89   3               if (SCH_tasks_G[Index].Period == 0)   //删除只运行一次的任务
  90   3                  {
  91   4                      SCH_Delete_Task(Index);
  92   4                  }
  93   3              }
  94   2         }
  95   1           
  96   1         SCH_Go_To_Sleep();    //单片机进入空闲模式      
  97   1      }
  98          
  99          
 100          //-----------------任务中断刷新------------------
 101          
 102          void SCH_Update(void) interrupt 5 
 103          {
 104   1      
 105   1         uchar  Index;
 106   1      
 107   1         TF2 = 0; 
 108   1      
 109   1         
 110   1         for (Index = 0; Index < SCH_MAX_TASKS; Index++)
 111   1         {
 112   2           
 113   2            if (SCH_tasks_G[Index].pTask)     // if pTask==0 ,that indicates this task has been deleted.
 114   2               {
C51 COMPILER V8.05a   SCH51                                                                11/09/2008 23:18:21 PAGE 3   

 115   3               if (SCH_tasks_G[Index].Delay == 0)
 116   3                  {
 117   4                 
 118   4                      SCH_tasks_G[Index].RunMe += 1;  // Indicate this task is ready for running.
 119   4      
 120   4                      if (SCH_tasks_G[Index].Period)  // if Period==0 , that indicates this task only execute one
             - time.
 121   4                      {
 122   5                         SCH_tasks_G[Index].Delay = SCH_tasks_G[Index].Period;
 123   5                       }
 124   4                  }
 125   3               else
 126   3                {
 127   4                  
 128   4                              SCH_tasks_G[Index].Delay -= 1;  // Delayed one Cycle 
 129   4                 }
 130   3               }         
 131   2          }
 132   1      }   
 133          
 134          
 135          //----------------系统初始化-------------------
 136          void SCH_Init_T2(void) 
 137          {
 138   1          uchar i;
 139   1      
 140   1          for (i = 0; i < SCH_MAX_TASKS; i++) 
 141   1          {
 142   2            SCH_Delete_Task(i);
 143   2          }
 144   1      
 145   1           T2CON = 0x00;       // TF2|EXF2 |RCLK|TCLK|EXEN2|TR2|C/T2|CP/RL2           ,when TCLK=1 and RCLK=1,Then TIMER2 use
             -d to Bandrate Generator!
 146   1           T2MOD = 0x00;  // -|-|-|-|-|T2OE|DCEN 
 147   1      
 148   1           TH2    = 0xFC; 
 149   1           RCAP2H = 0xFC; 
 150   1           TL2    = 0x18; 
 151   1           RCAP2L = 0x18;   // T2 add one each machine clock(about 12/11.0592 us),0xFC18=64536,Then about each (
             -65535-64536)*12/11.0592~=1.083ms overflow once;
 152   1         
 153   1           ET2   = 1;  
 154   1           TR2   = 1;  
 155   1      }
 156          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    541    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =     35    ----
   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 + -