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

📄 timers.lst

📁 silicon wireless开发套件F920+Si4432原理图,源码
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V8.00   TIMERS                                                                11/17/2008 10:50:42 PAGE 1   


C51 COMPILER V8.00, COMPILATION OF MODULE TIMERS
OBJECT MODULE PLACED IN timers.OBJ
COMPILER INVOKED BY: C:\Program Files\Keil\C51\BIN\C51.exe timers.c DB OE BR

line level    source

   1          /*
   2          ** ============================================================================
   3          **
   4          ** FILE
   5          **  timers.c
   6          **
   7          ** DESCRIPTION
   8          **  Contains the timer specific functions
   9          **
  10          ** CREATED
  11          **  Silicon Laboratories Hungary Ltd
  12          **
  13          ** COPYRIGHT
  14          **  Copyright 2008 Silicon Laboratories, Inc.  
  15          **      http://www.silabs.com
  16          **
  17          ** ============================================================================
  18          */
  19          /*------------------------------------------------------------------------*/
  20          /*                                              INCLUDE                                                                                   */
  21          /*------------------------------------------------------------------------*/
  22          #include "timers.h"
  23          
  24          
  25          /*------------------------------------------------------------------------*/
  26          /*                                              GLOBAL variables                                                                  */
  27          /*------------------------------------------------------------------------*/
  28          
  29          /*------------------------------------------------------------------------*/
  30          /*                                              LOCAL function prototypes                                                 */
  31          /*------------------------------------------------------------------------*/
  32          
  33          
  34          /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  35            +
  36            + FUNCTION NAME:  void StartTmr0( uint8 prescaler, uint16 period, uint8 it_enable)
  37            +
  38            + DESCRIPTION:    start TMR0 in the specified mode
  39            +
  40            +     INPUT:                  prescaler:              TMR0_48, TMR0_12, TMR0_4, TMR0_1
  41            +                                     period:                 the duration of the timing      
  42            +                                     it_enable:              TRUE - it enables the IT; FALSE - it disables 
  43            +                                                                     the IT (status should be polled)        
  44            +
  45            + RETURN:         
  46            +
  47            + NOTES:          
  48            +
  49            +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  50          void StartTmr0(uint8 prescaler, UU16 period, bit it_enable)
  51          {
  52   1              //setup timer
  53   1              TMOD = 0x11;                                            //TMR0 & TMR1 works in 16bit mode, independently of INT level
  54   1              CKCON = (CKCON & 0xF8) | prescaler;     //set prescaler
  55   1              
C51 COMPILER V8.00   TIMERS                                                                11/17/2008 10:50:42 PAGE 2   

  56   1      
  57   1              //set time period
  58   1              period.U16 = 65535 - period.U16;
  59   1              TH0 = period.U8[MSB];
  60   1              TL0 = period.U8[LSB];
  61   1      
  62   1              //enable IT if needed
  63   1              if( it_enable == TRUE )
  64   1              {
  65   2                      EnableTmr0It();
  66   2              }
  67   1              else
  68   1              {
  69   2                      DisableTmr0It();
  70   2              }
  71   1              EnableTmr0();
  72   1      }
  73          
  74          /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  75            +
  76            + FUNCTION NAME:  UU16 GetTmr0(void)
  77            +
  78            + DESCRIPTION:    gives back the actual value of TMR0
  79            +
  80            +     INPUT:                  None
  81            +
  82            + RETURN:         timer value
  83            +
  84            + NOTES:          
  85            +
  86            +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
  87          UU16 GetTmr0(void)
  88          {
  89   1              UU16 Temp16;
  90   1      
  91   1              Temp16.U8[MSB] = TH0;
  92   1              Temp16.U8[LSB] = TL0;
  93   1      
  94   1              return Temp16;
  95   1      }
  96          
  97          
  98          /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  99            +
 100            + FUNCTION NAME:  bit Tmr0Expired(void)
 101            +
 102            + DESCRIPTION:    returns with TRUE if TMR0 already expired, 
 103            +                                     otherwise returns with FALSE
 104            +
 105            +     INPUT:                  None
 106            +
 107            + RETURN:         TRUE / FALSE
 108            +
 109            + NOTES:          it clears the IT status flag!
 110            +
 111            +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
 112          bit Tmr0Expired(void)
 113          {
 114   1              if( TF0 == 0)
 115   1              {
 116   2                      return FALSE;
 117   2              }
C51 COMPILER V8.00   TIMERS                                                                11/17/2008 10:50:42 PAGE 3   

 118   1              else
 119   1              {       
 120   2                      StopTmr0();
 121   2                      return TRUE;
 122   2              }
 123   1      
 124   1      }
 125          
 126          
 127          /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 128            +
 129            + FUNCTION NAME:  void StartTmr1(uint8 prescaler, UU16 period, bit it_enable)
 130            +
 131            + DESCRIPTION:    start TMR1 in the specified mode
 132            +
 133            +     INPUT:                  prescaler:              TMR1_48, TMR1_12, TMR1_4, TMR1_1
 134            +                                     period:                 the duration of the timing      
 135            +                                     it_enable:              TRUE - it enables the IT; FALSE - it disables 
 136            +                                                                     the IT (status should be polled)        
 137            +
 138            + RETURN:         
 139            +
 140            + NOTES:          
 141            +
 142            +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
 143          void StartTmr1(uint8 prescaler, UU16 period, bit it_enable)
 144          {
 145   1              //setup timer
 146   1              //setup timer
 147   1              TMOD = 0x11;                                            //TMR0 & TMR1 works in 16bit mode, independently of INT level
 148   1              CKCON = (CKCON & 0xF4) | prescaler;     //set prescaler
 149   1              
 150   1              //set time period
 151   1              period.U16 = 65535 - period.U16;
 152   1              TH1 = period.U8[MSB];
 153   1              TL1 = period.U8[LSB];
 154   1      
 155   1              //enable IT if needed
 156   1              if( it_enable == TRUE )
 157   1              {
 158   2                      EnableTmr1It();
 159   2              }
 160   1              else
 161   1              {
 162   2                      DisableTmr1It();
 163   2              }
 164   1              EnableTmr1();
 165   1      }
 166          
 167          /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 168            +
 169            + FUNCTION NAME:  UU16 GetTmr1(void)
 170            +
 171            + DESCRIPTION:    gives back the actual value of TMR1
 172            +
 173            +     INPUT:                  None
 174            +
 175            + RETURN:         Value of the timer
 176            +
 177            + NOTES:          
 178            +
 179            +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
C51 COMPILER V8.00   TIMERS                                                                11/17/2008 10:50:42 PAGE 4   

 180          UU16 GetTmr1(void)
 181          {
 182   1              UU16 Temp16;
 183   1      
 184   1              Temp16.U8[MSB] = TH1;
 185   1              Temp16.U8[LSB] = TL1;
 186   1      
 187   1              return Temp16;
 188   1      }
 189          
 190          
 191          /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 192            +
 193            + FUNCTION NAME:  bit Tmr1Expired(void)
 194            +
 195            + DESCRIPTION:    returns with TRUE if TMR1 already expired, 
 196            +                                     otherwise returns with FALSE
 197            +
 198            +     INPUT:                  None
 199            +
 200            + RETURN:         TRUE / FALSE
 201            +
 202            + NOTES:          it clears the IT status flag!
 203            +
 204            +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
 205          bit Tmr1Expired(void)
 206          {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -