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

📄 os_cpu_c.lst

📁 sst51单片机
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.20   OS_CPU_C                                                              12/01/2008 17:16:03 PAGE 4   

              }
              #endif
 180          
 181          /*
 182          *********************************************************************************************************
 183          *                                          任务切换钩挂函数
 184          *
 185          * 描述       : 执行任务切换时调用。这允许你在上下文切换期间执行其它操作。
 186          *
 187          * 参数       : 无
 188          *
 189          * 注意       : 1) 调用期间中断被禁止
 190          *              2) 假定全局指针'OSTCBHighRdy'已经指向了将要被换入的任务控制块(即:最高优先级任务),并且
 191          *                 'OSTCBCur'指向了将被换出的任务(即:当前任务)。
 192          *********************************************************************************************************
 193          */
 194          void OSTaskSwHook (void) reentrant
 195          {
 196   1      }
 197          
 198          /*
 199          *********************************************************************************************************
 200          *                                          统计任务钩挂函数
 201          *
 202          * 描述       : 这个函数每秒钟被uC/OS-II统计任务调用。这么做使你的应用程序可以增加统计任务的功能。
 203          *
 204          * 注意       : 无
 205          *********************************************************************************************************
 206          */
 207          #if OS_TASK_STAT_EN > 0
              void OSTaskStatHook (void) reentrant
              {
              }
              #endif
 212          
 213          /*
 214          *********************************************************************************************************
 215          *                                           OSTCBInit() HOOK
 216          *
 217          * Description: This function is called by OSTCBInit() after setting up most of the TCB.
 218          *
 219          * Arguments  : ptcb    is a pointer to the TCB of the task being created.
 220          *
 221          * Note(s)    : 1) Interrupts may or may not be ENABLED during this call.
 222          *********************************************************************************************************
 223          */
 224          #if OS_VERSION > 203
 225          void OSTCBInitHook (OS_TCB *ptcb) reentrant
 226          {
 227   1          ptcb = ptcb;                                           /* Prevent Compiler warning                 */
 228   1      }
 229          #endif
 230          
 231          /*
 232          *********************************************************************************************************
 233          *                                          定时钩挂函数
 234          *
 235          * 描述       : 本函数每一滴答被调用一次。
 236          *
 237          * 参数       : 无
 238          *
 239          * 注意       : 1) 在本调用期间中断可以或不可以使能。
C51 COMPILER V7.20   OS_CPU_C                                                              12/01/2008 17:16:03 PAGE 5   

 240          *********************************************************************************************************
 241          */
 242          void OSTimeTickHook (void) reentrant
 243          {
 244   1      }
 245          
 246          /*
 247          *********************************************************************************************************
 248          *                                             IDLE TASK HOOK
 249          *
 250          * Description: This function is called by the idle task.  This hook has been added to allow you to do  
 251          *              such things as STOP the CPU to conserve power.
 252          *
 253          * Arguments  : none
 254          *
 255          * Note(s)    : 1) Interrupts are enabled during this call.
 256          *********************************************************************************************************
 257          */
 258          #if OS_VERSION >= 251
 259          void OSTaskIdleHook (void) reentrant
 260          {
 261   1      }
 262          #endif
 263          
 264          #endif
 265          
 266          /*
 267             使用C语言的中断处理函数有助与提高程序的移植性。建议中断程序不要太长,如果长则使用信号量来与任务同步,
 268             在外部任务中实现大量的处理。
 269             中断处理例程都放在下面。
 270          */
 271          
 272          void UserTickTimer(void)
 273          {
 274   1          TH0=0x70;                   //普通51定时器方式1,必须在发生中断时,重新赋值并再次启动计时
 275   1          TL0=0;              //Tick=50次/秒(即0.02秒/次),晶振22.1184M
 276   1          TR0=1;
 277   1      }
 278          
 279          /* 
 280            ucOS-II系统时钟中断处理程序
 281          */
 282          // sbit LED1=P1^0;
 283          void OSTickISR(void) interrupt 1
 284          {
 285   1          OSIntEnter();                                       // Must be called first at every hardware interrupt entry point 
 286   1          UserTickTimer();                            // User functions can be called here.
 287   1      //      LED1=0;
 288   1              OSTimeTick();                                   // Must be called during tick isr 
 289   1              OSIntExit();                                    // Must be called finally at every hardware interupt exit point 
 290   1      }
 291          
 292          /*--------------------------------------------------------------*/
 293          /* ucOS-II的中断服务程序示例                                    */
 294          /*--------------------------------------------------------------*/
 295          /*#include "source\serial.h"
 296          
 297          void SerialISR(void) interrupt 4
 298          {
 299          #if OS_CRITICAL_METHOD == 3         // Allocate storage for CPU status register 
 300              OS_CPU_SR  cpu_sr;
 301          #endif 
C51 COMPILER V7.20   OS_CPU_C                                                              12/01/2008 17:16:03 PAGE 6   

 302          
 303              OSIntEnter();                                       // Must be called first at every hardware interrupt entry point 
 304              OS_ENTER_CRITICAL();
 305              if(TI)
 306                  {
 307                    TI=0;
 308                pc_send.ptr++;
 309                if (pc_send.ptr < pc_send.count)
 310                  SBUF=pc_send.buffer[pc_send.ptr];
 311                  }
 312                  else if(RI)
 313                  {
 314                      RI=0;
 315          //处理输入字符
 316                  }
 317              OS_EXIT_CRITICAL();
 318          
 319                  OSIntExit();                    // Must be called finally at every hardware interupt exit point 
 320          }*/
 321          
 322          
 323          /*------------------------------
 324            设置硬件寄存器的初始值。
 325            初始化定时器0,作为ucOS-II的系统时钟。
 326            还有其他的与硬件相关的初始化也可以放在这里。
 327          --------------------------------*/
 328          
 329          //串口初始化  0xfd=19200,0xfa=9600,0xf4=4800,0xe8=2400,0xd0=1200
 330          void InitHardware(void) reentrant
 331          {   
 332   1          TMOD = 0x21;   //定时器0:模式1(16位定时器),仅受TR0控制;定时器1:波特率发生器
 333   1          TH0  = 0x70;   //定义Tick=50次/秒(即0.02秒/次),TH,TL值与CPU的频率有关(22.1184M)
 334   1          TL0  = 0x00;   //OS_CPU_C.C中定时器中断响应也要设置,OS_CFG.H中OS_TICKS_PER_SEC也有关系
 335   1          //ET0  = 1;    //允许T0中断(在第一个任务开始执行时才开时钟中断,否则万一中断系统进入不可知状态)
 336   1          TR0  = 1;
 337   1      
 338   1          TH1   = 0xFA;  //晶振22.1084, 波特率 9600
 339   1          ET1   = 0;
 340   1          TR1   = 1;     //start timer1
 341   1          SCON  = 0x50;
 342   1          ES    = 1;
 343   1      
 344   1          //设置串口收发的初始值
 345   1      //    pc_send.ptr=0;
 346   1      //    pc_send.count=0;
 347   1              ET0=1;  //开时钟节拍中断
 348   1      }


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