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

📄 blinky.lst

📁 C8051F06X系列单片机的C语言编程实例
💻 LST
字号:
C51 COMPILER V7.05   BLINKY                                                                06/14/2005 10:15:59 PAGE 1   


C51 COMPILER V7.05, COMPILATION OF MODULE BLINKY
OBJECT MODULE PLACED IN blinky.OBJ
COMPILER INVOKED BY: C:\SiLabs\MCU\IDEfiles\C51\BIN\C51.exe blinky.c DB OE

stmt level    source

   1          //------------------------------------------------------------------------------------
   2          // Blinky.c
   3          //------------------------------------------------------------------------------------
   4          // Copyright (C) 2004 Silicon Laboratories, Inc.
   5          //
   6          // AUTH: BD
   7          // DATE: 26 SEP 2002
   8          //
   9          // This program flashes a LED on the C8051F060 target board about five times
  10          // a second using the interrupt handler for Timer3.
  11          // The LED should be connected to P1.6
  12          // Target: C8051F06x
  13          //
  14          // Tool chain: KEIL Eval 'c'
  15          //
  16          
  17          //------------------------------------------------------------------------------------
  18          // Includes
  19          //------------------------------------------------------------------------------------
  20          #include <c8051f060.h>                    // SFR declarations
  21          
  22          //-----------------------------------------------------------------------------
  23          // 16-bit SFR Definitions for 'F06x
  24          //-----------------------------------------------------------------------------
  25          
  26          sfr16 RCAP3    = 0xCA;                    // Timer3 reload value
  27          sfr16 TMR3     = 0xCC;                    // Timer3 counter
  28          
  29          //------------------------------------------------------------------------------------
  30          // Global CONSTANTS
  31          //------------------------------------------------------------------------------------
  32          
  33          #define SYSCLK 3062500                    // approximate SYSCLK frequency in Hz
  34          
  35          sbit  LED = P1^6;                         // LED: '1' = ON; '0' = OFF
  36          
  37          //------------------------------------------------------------------------------------
  38          // Function PROTOTYPES
  39          //------------------------------------------------------------------------------------
  40          void PORT_Init (void);
  41          void Timer3_Init (int counts);
  42          void Timer3_ISR (void);
  43          
  44          //------------------------------------------------------------------------------------
  45          // MAIN Routine
  46          //------------------------------------------------------------------------------------
  47          void main (void) {
  48   1      
  49   1         // disable watchdog timer
  50   1         WDTCN = 0xde;
  51   1         WDTCN = 0xad;
  52   1      
  53   1         PORT_Init ();
  54   1      
  55   1         Timer3_Init (SYSCLK / 12 / 10);        // Init Timer3 to generate interrupts
C51 COMPILER V7.05   BLINKY                                                                06/14/2005 10:15:59 PAGE 2   

  56   1                                                // at a 10 Hz rate.
  57   1         EA = 1;                                                                                      // enable global interrupts
  58   1      
  59   1         SFRPAGE = LEGACY_PAGE;                 // Page to sit in for now
  60   1      
  61   1         while (1) {                            // spin forever
  62   2      
  63   2         }
  64   1      }
  65          
  66          //------------------------------------------------------------------------------------
  67          // PORT_Init
  68          //------------------------------------------------------------------------------------
  69          //
  70          // Configure the Crossbar and GPIO ports
  71          //
  72          void PORT_Init (void)
  73          {
  74   1      char old_SFRPAGE;
  75   1      
  76   1         old_SFRPAGE = SFRPAGE;                 // Save old SFRPAGE
  77   1         SFRPAGE = CONFIG_PAGE;                 // Switch to configuration page
  78   1      
  79   1         XBR2    = 0x40;                        // Enable crossbar and weak pull-ups
  80   1         P1MDOUT |= 0x40;                       // enable P1.6 (LED) as push-pull output
  81   1      
  82   1         SFRPAGE = old_SFRPAGE;                 // restore SFRPAGE
  83   1      }
  84          
  85          //------------------------------------------------------------------------------------
  86          // Timer3_Init
  87          //------------------------------------------------------------------------------------
  88          //
  89          // Configure Timer3 to auto-reload and generate an interrupt at interval
  90          // specified by <counts> using SYSCLK/12 as its time base.
  91          //
  92          //
  93          void Timer3_Init (int counts)
  94          {
  95   1      char old_SFRPAGE;
  96   1      
  97   1         old_SFRPAGE = SFRPAGE;                 // Save old SFRPAGE
  98   1         SFRPAGE = TMR3_PAGE;                   // Switch to Timer 3 page
  99   1         
 100   1         TMR3CN = 0x00;                         // Stop Timer3; Clear TF3;
 101   1                                                // use SYSCLK/12 as timebase
 102   1         RCAP3   = -counts;                     // Init reload values
 103   1         TMR3    = 0xffff;                      // set to reload immediately
 104   1         EIE2   |= 0x01;                        // enable Timer3 interrupts
 105   1         TR3 = 1;                               // start Timer3
 106   1      
 107   1         SFRPAGE = old_SFRPAGE;                 // restore SFRPAGE
 108   1      
 109   1      }
 110          
 111          //------------------------------------------------------------------------------------
 112          // Interrupt Service Routines
 113          //------------------------------------------------------------------------------------
 114          
 115          //------------------------------------------------------------------------------------
 116          // Timer3_ISR
 117          //------------------------------------------------------------------------------------
C51 COMPILER V7.05   BLINKY                                                                06/14/2005 10:15:59 PAGE 3   

 118          // This routine changes the state of the LED whenever Timer3 overflows.
 119          //
 120          // NOTE: The SFRPAGE register will automatically be switched to the Timer 3 Page
 121          // When an interrupt occurs.  SFRPAGE will return to its previous setting on exit
 122          // from this routine.
 123          //
 124          void Timer3_ISR (void) interrupt 14
 125          {
 126   1         TF3 = 0;                               // clear TF3
 127   1         LED = ~LED;                            // change state of LED
 128   1      }
 129          
 130          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =     73    ----
   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 + -