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

📄 timer.lst

📁 一个基于XMODEM协议的下载字库的程序
💻 LST
字号:
C51 COMPILER V7.50   TIMER                                                                 06/22/2006 09:45:43 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE TIMER
OBJECT MODULE PLACED IN .\myproject\TIMER.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE TIMER.C LARGE OPTIMIZE(5,SPEED) BROWSE DEBUG OBJECTEXTEND OBJECT(.\myprojec
                    -t\TIMER.obj)

line level    source

   1          #define TIMER_PARA
   2          #include "config.h"
   3          
   4          static unsigned char timer0_tick;
   5          /*******************************************************************************
   6          程序名:timer0_isr
   7          说  明:定时器0中断服务程序,提供系统是中,每10ms中断一次,timer0_tick为可调的时基
   8          ********************************************************************************/
   9          void timer0_isr (void) interrupt TF0_VECTOR using 0
  10          {
  11   1              TR0 = 0;                                                /* stop timer 0 */
  12   1              TH0 = PERIODH0;
  13   1          TL0 = PERIODL0;                         //10ms
  14   1              TR0 = 1;                                                /* start timer 0 */
  15   1              
  16   1              timer0_tick++;                                  
  17   1              if(stimer_tick < 200)  stimer_tick++;   //防止溢出,很重要
  18   1              if(led_tick < 200)         led_tick++;
  19   1              if(others_tick<200)        others_tick++;
  20   1      }
  21          /*******************************************************************************
  22          程序名:timer0_init
  23          说  明:定时器0初始化程序,包括软定时器初始化
  24          ********************************************************************************/
  25          void timer0_init (void)
  26          {
  27   1              INT_DISABLE;                                    /* disable interrupts */
  28   1              TR0 = 0;                                /* stop timer 0 */
  29   1              TMOD &= 0xF0;                   /* clear timer 0 mode bits - bottom 4 bits */
  30   1              TMOD |= 0x01;                   /* put timer 0 into 16-bit no prescale */
  31   1              TH0   = PERIODH0;
  32   1          TL0   = PERIODL0;           //定时器0赋初值,定时器0每10ms中断一次
  33   1      
  34   1              PT0 = 0;                                /* set low priority interrupt for timer 0 */
  35   1              ET0 = 1;                                /* enable timer 0 interrupt */
  36   1              TR0 = 1;                                /* start timer 0 */
  37   1      
  38   1              vSoftTimer_Init();
  39   1              
  40   1              stimer_tick = 0;
  41   1              led_tick    = 0;
  42   1              timer0_tick = 0;
  43   1              INT_ENABLE;                                     /* enable interrupts */
  44   1      }
  45          /*------------------------------------------------------------------------------
  46          程序名:   timer0_count
  47          说  明:   返回当前timer0_tick的值
  48          ------------------------------------------------------------------------------*/
  49          unsigned char timer0_count(void)
  50          {
  51   1              unsigned char t;
  52   1      
  53   1              INT_DISABLE;            // disable interrupts to read a non-changing value
  54   1              t = timer0_tick;
C51 COMPILER V7.50   TIMER                                                                 06/22/2006 09:45:43 PAGE 2   

  55   1              INT_ENABLE;                     // enable interrupts
  56   1              return(t);
  57   1      }
  58          /*------------------------------------------------------------------------------
  59          程序名:   timer0_delay
  60          说  明:   延时子程序,延时时间为count*10ms
  61          ------------------------------------------------------------------------------*/
  62          void timer0_delay(unsigned char count)
  63          {
  64   1              unsigned char start_count;
  65   1      
  66   1              start_count = timer0_count(); /* get the start count */
  67   1              while ((timer0_count() - start_count) <= count)   /* wait for count "ticks" */
  68   1              {
  69   2                  PCON |= 0x01;    // Idle MCU to wait for timer tick
  70   2              }
  71   1      }
  72          /*------------------------------------------------------------------------------
  73          程序名:   delay_10ms
  74          说  明:   延时100ms
  75          ------------------------------------------------------------------------------*/
  76          void delay_10ms()               
  77          { 
  78   1              timer0_delay(2);
  79   1      }
  80          /*------------------------------------------------------------------------------
  81          程序名:   delay_100ms
  82          说  明:   延时100ms
  83          ------------------------------------------------------------------------------*/
  84          void delay_50ms()               
  85          { 
  86   1              timer0_delay(5);
  87   1      }
  88          /*------------------------------------------------------------------------------
  89          程序名:   delay_100ms
  90          说  明:   延时100ms
  91          ------------------------------------------------------------------------------*/
  92          void delay_100ms()              
  93          { 
  94   1              timer0_delay(10);
  95   1      }
  96          /*------------------------------------------------------------------------------
  97          程序名:   delay_1sec
  98          说  明:   延时1s
  99          ------------------------------------------------------------------------------*/
 100          void delay_1sec()               
 101          { 
 102   1              timer0_delay(100);
 103   1      }


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